Home Gradient of implicit symbolic expression in Matlab
Reply: 0

Gradient of implicit symbolic expression in Matlab

user1283
1#
user1283 Published in May 26, 2018, 11:39 pm
 The situation I have is as follows: I have a symbolic expression like: syms X Y Z K Ra=51.7; P=[0 0 200]; Sa=sym('Ra^2==(Z-P(3))^2+(Y-P(2))^2')  Where Y and Z are defined as symbolic. Ra and P are vectors. I need to get the gradient of Sa but I get an error: G=gradient(Sa,[Y Z]); Error using symengine (line 59) The first argument must be of type 'Type::Arithmetical'. Error in sym/gradient (line 39) res = mupadmex('symobj::gradient',fsym.s,x.s);  But if I write the same expression as: Sa(Y,Z)=((Z-P(3))^2+(Y-P(2))^2-Ra^2);  I get the expected result G=gradient(Sa,[Y Z]) G(X, Y, Z) = 2*Y 2*Z - 400  Does anyone knows why this is so and if there's any way of using the implicit expression as this is a particular case but in general I have different implicit expressions and my code should be able to deal with them. I've read the documentation on gradient and some sites, but if I found the answer I didn't notice. I believe I could use the second form but still, I am curious about this subject. Thanks for your time.
 You need to login account before you can post.
Processed in 0.3078 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO