how to do vector symbolic differentiation

10 visualizaciones (últimos 30 días)
Aamna Alshehhi
Aamna Alshehhi el 3 de Nov. de 2019
Comentada: Walter Roberson el 3 de Nov. de 2019
could I get help in writing vector symbolic differentiation
I wanna declare LA , Th2_2 ,ThA_2 as vectors where their values are seted in vector (1,11) for differtent time . note that each value of LA, Th2_2 and ThA_2 correspond to each other for the same time. so they must be used in the equation based on that.
how can I edit the code to get the solutions for Om2 and OmA as vectors as well
Thanks in advance for any help..
%Parameters
syms L1_2 L2_2 Th1 Th1_2 integer
% variables and their derivatives
syms LA Th2_2 Om2 ThA_2 OmA integer
%loop eqn.
L_eqn1 = L2_2*exp(1i*Th2_2)+LA.*exp(1i*ThA_2) -L1_2*exp(1i*Th1_2)==0;
%velocity eqn for Om2 and OmA.
dL_eqn1 = diff(L_eqn1,Th2_2)*Om2 +diff(L_eqn1,ThA_2)*OmA- v*exp(1i*ThA_2);
real_vel_eqn1 = real(dL_eqn1);
imag_vel_eqn1 = imag(dL_eqn1);
[Om2, OmA]=solve (real_vel_eqn1, imag_vel_eqn1);
  6 comentarios
Aamna Alshehhi
Aamna Alshehhi el 3 de Nov. de 2019
I dont want variables to be integar so I changed to real
%Parameters
syms L1 L2 L3 L4 L1_2 L2_2 Th1 Th1_2 real
% variables and their derivatives
LA = sym('LA', [1 11], 'real');
ThA_2 = sym('ThA_2', [1 11], 'real');
Th2_2 = sym('Th2_2', [1 11], 'real');
Om2 = sym('Om2', [1 11], 'real');
OmA = sym('OmA', [1 11], 'real');
%loop eqn.
L_eqn1 = L2_2*exp(1i*Th2_2)+ LA.*exp(1i*ThA_2) -L1_2*exp(1i*Th1_2)==0;
%velocity eqn for Om2 and OmA.
dL_eqn1 = diff(L_eqn1,Th2_2)*Om2 +diff(L_eqn1,ThA_2)*OmA- v*exp(1i*ThA_2)==0;
real_vel_eqn1 = real(dL_eqn1)==0;
imag_vel_eqn1 = imag(dL_eqn1)==0;
[Om2, OmA]=solve (real_vel_eqn1, imag_vel_eqn1);
Walter Roberson
Walter Roberson el 3 de Nov. de 2019
diff(L_eqn1,Th2_2)
You are asking to differentiate the vector L_eqn1 at the vector of variables Th2_2 . With the vectors being the same length, perhaps you are wanting to differentiate with corresponding variables. A single diff() call will not do that, but you can
arrayfun(@diff, L_eqn1, Th2_2)
Keep in mind, though, that you are differentiating an equation, which is going to have the effect of differentiating both sides of the equation. It is legal to then multiply by a constant, which has the effect of multiplying both sides by a constant, and it is legal to add equations... but when you find yourself multiplying or adding equations, you should stop to ask yourself whether that is really what you want to do, or if instead you should be working with just the expressions rather than the equations.

Iniciar sesión para comentar.

Respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by