Symbolic Derivative in matlab
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
0 votes
Share a link to this question
Can matlab diffrentiate F with respect to θ , ϕ and ψ only ?.
Any help is apperciated
Accepted Answer
KSSV
on 17 Aug 2020
0 votes
Share a link to this answer
You can carry on symbolic calculations. Read about diff.
7 Comments
HN
on 17 Aug 2020
I've tried it but it differentiate variables that supposed to be assumed constant.
The following is the comman I used
V=simplify(diff(f,theta)+diff(f,psi)+diff(f,phi));
gives
EX, α is constant should not differentiated but the result is diffrent. So, I am confused if I make mistake or matlab cannot deal with this ?
KSSV
on 17 Aug 2020
Share a link to this comment
Copy your code, which you have tried.
syms phi theta psi dphi dtheta dpsi rp L alpha beta
x = @(t) -rp*(cos(t)*cos(t)+sin(t)*sin(t)*sin(t))*cos(alpha)-rp*(-cos(t)*sin(t)+sin(t)*sin(t)*cos(t))*sin(alpha)+(rp/tan(alpha))*(cos(t)*sin(t)*(cos(alpha)-1)+cos(t)*cos(t)*sin(alpha));
dx=diff(x,theta)*dpsi+diff(x,psi)*dpsi+diff(x,psi)*dphi
It gives
dpsi*(rp*cos(alpha)*(cos(phi)*sin(theta) - cos(theta)*sin(phi)*sin(psi)) - rp*sin(alpha)*(sin(phi)*sin(theta) + cos(phi)*cos(theta)*sin(psi))) - dphi*((rp*sin(psi)*(sin(alpha + phi) - sin(phi)))/tan(alpha) + rp*cos(alpha)*cos(psi)*sin(phi)*sin(theta) + rp*cos(phi)*cos(psi)*sin(alpha)*sin(theta)) - dpsi*((rp*sin(psi)*(sin(alpha + phi) - sin(phi)))/tan(alpha) + rp*cos(alpha)*cos(psi)*sin(phi)*sin(theta) + rp*cos(phi)*cos(psi)*sin(alpha)*sin(theta))
But it is wrong
KSSV
on 18 Aug 2020
syms t a x(t) y(t)
f = a*(cos(x)+sin(x)) ;
diff(f,t)
HN
on 18 Aug 2020
How about the symbolic division as below. matlab says undefined operator .
R = -A*(cos(t)-cos(t))+B*cos(th)*sin(t);
S = A*sin(t)*sin(t)-B*cos(t)+C*cos(t);
phi=atan(R/S)
KSSV
on 18 Aug 2020
syms A B C t th
R = -A*(cos(t)-cos(t))+B*cos(th)*sin(t);
S = A*sin(t)*sin(t)-B*cos(t)+C*cos(t);
phi=atan(R/S)
Why running on live script and script gives different result for the same expression?
syms syms t phi(t) theta(t) psi(t) dphi dtheta dpsi rp L alpha beta
x=rp*sin(alpha)*(cos(theta)*sin(phi) - cos(phi)*sin(psi)*sin(theta)) - rp*cos(alpha)*(cos(phi)*cos(theta) + sin(phi)*sin(psi)*sin(theta)) + (rp*cos(psi)*(sin(alpha + phi) - sin(phi)))/tan(alpha)
diff(x, t)
using matlab mlx and matlab script. Both gives different result
mlx gives
vx=rp*cos(psi(t))*cos(theta(t))*sin(phi(t))*sin(alpha) - rp*cos(phi(t))*cos(psi(t))*cos(theta(t))*cos(alpha)
while running on matlab script gives
vx=((rp*cos(psi(t))*(cos(alpha + phi(t)) - cos(phi(t)))*diff(phi(t), t))/tan(alpha) - rp*sin(alpha)*(sin(phi(t))*sin(theta(t))*diff(theta(t), t) - cos(phi(t))*cos(theta(t))*diff(phi(t), t) + cos(phi(t))*cos(psi(t))*sin(theta(t))*diff(psi(t), t) + cos(phi(t))*cos(theta(t))*sin(psi(t))*diff(theta(t), t) - sin(phi(t))*sin(psi(t))*sin(theta(t))*diff(phi(t), t)) - rp*cos(alpha)*(cos(phi(t))*sin(psi(t))*sin(theta(t))*diff(phi(t), t) - cos(phi(t))*sin(theta(t))*diff(theta(t), t) - cos(theta(t))*sin(phi(t))*diff(phi(t), t) + cos(psi(t))*sin(phi(t))*sin(theta(t))*diff(psi(t), t) + cos(theta(t))*sin(phi(t))*sin(psi(t))*diff(theta(t), t)) - (rp*sin(psi(t))*(sin(alpha + phi(t)) - sin(phi(t)))*diff(psi(t), t))/tan(alpha))
More Answers (0)
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
See Also
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)