how to differentiate and plot of this function

조회 수: 7 (최근 30일)
shiv gaur
shiv gaur 2022년 1월 25일
댓글: Hiro Yoshino 2022년 1월 25일
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
KSSV
KSSV 2022년 1월 25일
Did you try to run the code and see?
r1=(k1-k2)/(k1+k2);
What is d2 and d3?

댓글을 달려면 로그인하십시오.

답변 (1개)

Hiro Yoshino
Hiro Yoshino 2022년 1월 25일
편집: Hiro Yoshino 2022년 1월 25일
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)
k1 = 
k2 = sqrt(2-x^2)
k2 = 
k3 = sqrt(3-x^2)
k3 = 
k4 = sqrt(4-x^2)
k4 = 
r1 = (k1-k1)/(k1+k2)
r1 = 
0
r2 = (k3-k4)/(k3+k4)
r2 = 
r3 = (k2-k3)/(k2+k3)
r3 = 
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))
y = 
dydx = diff(y,x)
dydx = 
dydd3 = diff(y,d2)
dydd3 = 
dydd4 = diff(y,d3)
dydd4 = 
  댓글 수: 2
shiv gaur
shiv gaur 2022년 1월 25일
is there any method with out syms pl plot the solve equation
Hiro Yoshino
Hiro Yoshino 2022년 1월 25일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by