how to differentiate and plot of this function
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
k1= @(x) sqrt(1-x^2);
k2=@(x) sqrt(2-x^2);
k3=@(x) sqrt(3-x^2);
k4=@(x) sqrt(4-x^2);
r1=@(x) (k1-k2)/(k1+k2);
r2=@(x) (k3-k4)/(k3+k4);
r3= @(x) (k2-k3)/(k2+k3);
y=@(x,d2,d3) -2*atan(1i*(1-r1)/(1+r1))*exp((1-r2*k1*d2)/(1+r2*km*d2))--2*atan(1i*(1-r3)/(1+r3))*exp((1-k2*d3)/(1+r4*k2*d3));
how to calculate dy/dx dy/dd2 and dy/dd3
plot d2 vs dy/dd2/dy/dd3
variation of d2 from 1 to 100;
y is multivariable depending upon d2,d3 x
1 comentario
KSSV
el 25 de En. de 2022
Did you try to run the code and see?
r1=(k1-k2)/(k1+k2);
What is d2 and d3?
Respuestas (1)
Hiro Yoshino
el 25 de En. de 2022
Editada: Hiro Yoshino
el 25 de En. de 2022
Why don't you use symbolic math expressions as follows?
Please run the script below:
syms k1(x) k2(x) k3(x) k4(x) r1(x) r2(x) r3(x) y(x,d2,d3)
k1 = sqrt(1-x^2)
k2 = sqrt(2-x^2)
k3 = sqrt(3-x^2)
k4 = sqrt(4-x^2)
r1 = (k1-k1)/(k1+k2)
r2 = (k3-k4)/(k3+k4)
r3 = (k2-k3)/(k2+k3)
Note that the first term (atan) does not work due to its singularity and you've got some typos in the expression and I corrected as follows:
y = -2*atan((1-r1)/(1+r1)) *exp((1-r2*k1*d2)/(1+r2*k1*d2))-2*atan(1i*(1-r3)/(1+r3))*exp((1-k2*d3)/(1+r3*k2*d3))
dydx = diff(y,x)
dydd3 = diff(y,d2)
dydd4 = diff(y,d3)
2 comentarios
Hiro Yoshino
el 25 de En. de 2022
I don't think what you want to do is solve anything. I suppose you want to derive the partial derivatives.
Iif you want to get the analytic forms of the derivatives, use Symbolic Math otherwise numerical derivative would be a good fit.
The easiest way to use numerical derivative is use "approximation" such as numerical derivatives - you can chop the variables into small intervals and perform the calculations as shown in the document.
Ver también
Categorías
Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!