Why does MATLAB dot product function interpret r as 2 different variables. I want to use trigonometric identities. How can I fix it?

3 views (last 30 days)
syms x y z u v r a
x=(a+r.*cos(u)).*cos(v);
y=(a+r.*cos(u)).*sin(v);
z=r.*sin(u);
X=[x y z]
X = 
Xu=diff(X,u)
Xu = 
Xv=diff(X,v)
Xv = 
E=dot(Xu,Xu)
E = 
simplify(E)
ans = 

Accepted Answer

Steven Lord
Steven Lord on 12 Nov 2021
If you want MATLAB to assume that r is real, tell it that.
syms r1 % r1 could be complex
syms r2 real % r2 must be real
x1 = dot(r1, r1)
x1 = 
x2 = dot(r2, r2)
x2 = 

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by