differentiation in matlab of two functions

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
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
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

Hi Stephan,I wouId like to thank for ur answer ,
In my code
syms a(theta) p q A s(a)
eq1 = a(theta)==atan(p/q)+pi;
eq2 = s(a)==exp(2*pi*1i*A*[cos(a(theta));sin(a(theta))]);
Deq1 = diff(eq2,a(theta));
sol = subs(rhs(Deq1),a(theta),rhs(eq1));
Here a is function theta and s is function of a
Is this Correct?
And I have two doubts,
  1. In my case A is 1*2 matrix,but here it is taking as 1*1 matrix finally am getting size (Deq1) is 2*1 since [cos(a(theta));sin(a(theta))] is 2*1 size..How to make size(Deq1) is 1*1?
  2. After getting this sol,i have to multiply this with 0.68 but the result am getting here is zero .how to make it finite ??
Stephan
Stephan le 3 Déc 2020
Modifié(e) : Stephan 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.
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.
After getting sol from above
A=Amat;p=porg;q=qorg;
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)));
sola = subs(sol,A,Amat);
solb = subs(sola,p,porg);
solc = subs(solb,q,qorg);
Is this correct?
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
Thank u so much,It helped me a lot
Stephan
Stephan le 4 Déc 2020
Did you notice that you can accept and/or vote for useful answers?

Connectez-vous pour commenter.

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!

Translated by