I need help with Symbolic Differentiation Error
Show older comments
Hello MATLAB community,
I am trying to do partial differentiation to find a 6x3 (Jr) matrix, but I am getting an error which says:
" Second argument must be a variable or a nonnegative integer specifying the number of differentiations."
I tried to play around by changing the code, but the problem is still the same.
Below is my code:
syms phi theta psi Psi
h = 110.75;
d2r = pi/180;
r2d = 180/pi;
ROT = [(cos(phi)*cos(psi))-(cos(theta)*sin(phi)*sin(psi)) -(cos(phi)*sin(psi))-(cos(theta)*cos(psi)*sin(phi)) (sin(phi)*sin(theta));...
(cos(psi)*sin(phi))+(cos(phi)*cos(theta)*sin(psi)) (cos(phi)*cos(theta)*cos(psi)-sin(phi)*sin(psi)) -(cos(phi)*sin(theta));...
(sin(theta)*sin(psi)) (cos(psi)*sin(theta)) cos(theta)];
px = (h/2)*(ROT(1,1)-ROT(2,2));
py = -h*ROT(2,1);
eqn = ROT(1,2) == ROT(2,1);
Psi = eqn;
pz = input('Please enter value for pz: ');
phi = input('Please enter value for phi: ')*d2r;
theta = input('Please enter value for theta: ')*d2r;
if phi >= 0
psi = -phi ;
elseif phi <= 0
psi = -phi ;
end
jr = [diff(px, pz), diff(px, phi), diff(px, theta); diff(py, pz), diff(py, phi), diff(py, theta); 1, 0, 0; 0, 1, 0; 0, 0, 1; diff(Psi, pz), diff(Psi, phi), diff(Psi, theta)];
Jr = double(subs(jr,{phi,theta,psi},{phi,theta,psi}))
You can assume the values for pz, phi, theta to be 435, 5, and 10, respectively.
Can anyone please help me with this problem.
Kind regards,
Shiv
Accepted Answer
More Answers (0)
Categories
Find more on Numeric Solvers in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!