differentiation in matlab of two functions
Afficher commentaires plus anciens
Let
theta=atan(p/q)+pi
a(theta)=exp(2*pi*j*A*[cos(theta);sin(theta)]) where A ,is row vector and p,q,A are known
I need to find the
in matlab.Please help me on this
Réponses (2)
Alan Stevens
le 3 Déc 2020
a = @(theta) exp(2j*pi*A*[cos(theta);sin(theta)]);
dadtheta = @(theta) 2j*pi*A*[-sin(theta);cos(theta)]*a(theta);
Stephan
le 3 Déc 2020
syms a(theta) p q A
eq1 = a(theta)==exp(2*pi*1i*A*[cos(theta);sin(theta)])
eq2 = theta==atan(p/q)+pi
Deq1 = diff(eq1,theta)
sol = subs(rhs(Deq1),theta,rhs(eq2))
pretty(sol)
6 commentaires
Murali Krishna AG
le 3 Déc 2020
I dont think, that
is really a function of theta - if we derive this w.r.t. theta the answer is zero - theta is just determined by
and i think this is not a functoin of theta.
is really a function of theta - if we derive this w.r.t. theta the answer is zero - theta is just determined by
and i think this is not a functoin of theta.Regarding the size of the result, in case of A is of size 1x2 the result is 1x1:
syms s(theta) theta p q
A = sym('A', [1 2])
eq1 =s(theta)==exp(2*pi*1i*A*[cos(theta);sin(theta)])
eq2 = theta==atan(p/q)+pi;
Deq1 = diff(eq1,theta)
sol = subs(rhs(Deq1),theta,rhs(eq2))
This results in:
A =
[ A1, A2]
eq1 =
s(theta) == exp(pi*A1*cos(theta)*2i + pi*A2*sin(theta)*2i)
Deq1 =
diff(s(theta), theta) == exp(pi*A1*cos(theta)*2i + pi*A2*sin(theta)*2i)*(pi*A2*cos(theta)*2i - pi*A1*sin(theta)*2i)
sol =
-exp(- (A1*pi*2i)/(p^2/q^2 + 1)^(1/2) - (A2*p*pi*2i)/(q*(p^2/q^2 + 1)^(1/2)))*((A2*pi*2i)/(p^2/q^2 + 1)^(1/2) - (A1*p*pi*2i)/(q*(p^2/q^2 + 1)^(1/2)))
For the multiplication:
>> sol = 0.68*sol
sol =
-(17*exp(- (A1*pi*2i)/(p^2/q^2 + 1)^(1/2) - (A2*p*pi*2i)/(q*(p^2/q^2 + 1)^(1/2)))*((A2*pi*2i)/(p^2/q^2 + 1)^(1/2) - (A1*p*pi*2i)/(q*(p^2/q^2 + 1)^(1/2))))/25
You could now use subs on this result and substitue A1 with the value of A(1), A2 with the value of A(2)... to get an symbolic result.
Murali Krishna AG
le 4 Déc 2020
Stephan
le 4 Déc 2020
syms A1 A2 p q
sol = -exp(- (A1*pi*2i)/(p^2/q^2 + 1)^(1/2) - (A2*p*pi*2i)/...
(q*(p^2/q^2 + 1)^(1/2)))*((A2*pi*2i)/(p^2/q^2 + 1)^(1/2) -...
(A1*p*pi*2i)/(q*(p^2/q^2 + 1)^(1/2)));
Amat = [0.5 2.5];
porg = 3;
qorg = -1;
sol_new = subs(sol, [A, p, q], [Amat, porg, qorg])
num_result = vpa(sol_new)
gives:
sol_new =
-(10^(1/2)*pi*exp((pi*10^(1/2)*7i)/5)*4i)/5
num_result =
7.7406505609803157366313776809726 - 1.8021645484713704266844120210115i
Murali Krishna AG
le 4 Déc 2020
Stephan
le 4 Déc 2020
Did you notice that you can accept and/or vote for useful answers?
Catégories
En savoir plus sur Programming dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!