Let us say there is a fucntion theta that is depedent on time: Theta(t); It is in a cos function so: cos(theta(t))
How do i differentiate this in matlab so it uses the chain rule?
clear all
syms t theta
theta=t;
f=cos(theta(t));
diff(f,t)
I have tried the above and got the errors:
Error using sym/subsref (line 49)
Error using maplemex
Error, (in MTM:-subsref) indices must be positive integers, got t
Error in test (line 5)
f=cos(theta(t));

 채택된 답변

Star Strider
Star Strider 2021년 10월 11일
I suspect this works the similiarly in Maple (that I do not currently have) —
syms t theta(t)
f=cos(theta(t));
dfdt(t) = diff(f,t)
dfdt(t) = 
.

댓글 수: 7

Hamza Yusuf
Hamza Yusuf 2021년 10월 11일
편집: Hamza Yusuf 2021년 10월 11일
I have tried to google after this error and which -all syms did not work
I get this error:
Error using assignin
Invalid variable name "theta(t)" in ASSIGNIN.
Error in syms (line 56)
assignin('caller',varargin{i},sym(varargin{i}));
Error in test (line 1)
syms t theta(t)
Star Strider
Star Strider 2021년 10월 11일
Maple may work differently than the MATLAB Symbolic Math Toolbox engine.
Check the Maple documentation, since my code obviously works in MATLAB R2021b.
I currently do not have Maple installed, so I cannot help with code using it.
.
Hamza Yusuf
Hamza Yusuf 2021년 10월 11일
I am using 2020b. I am not using maple. I dont know why it says "Error using maplemex" but i am using matlab
Star Strider
Star Strider 2021년 10월 11일
This error —
Error using maplemex
indicates that Maple is the symbolic engine in the posted original code.
.
How do i change it to matlab`?
I have found this:
But that it did not work and this happened:
>> which -all syms
C:\Program Files\MATLAB\R2020b\toolbox\maple\syms.m
C:\Program Files\MATLAB\R2020b\toolbox\symbolic\symbolic\syms.m % Shadowed
>> test
Error using sym/subsref (line 49)
Error using maplemex
Error, (in MTM:-subsref) indices must be positive integers, got t
Error in test (line 2)
f=cos(theta(t));
The other solution i did not get: Where do i have to look for the uninstaller?
Hamza Yusuf
Hamza Yusuf 2021년 10월 11일
The other solution where you remove the matlab directory worked. Thank you,
Star Strider
Star Strider 2021년 10월 11일
I hope that you do not have to uninstall Maple, and can simply disconnect it from MATLAB.
However if you need to uninstall it (and then reinstall it without connecting it to MATLAB next time), and since it appears that you are using Windows, open Control Panel, then click on Programs and Features, then follow the instructions. Then, reinstall Maple without connecting it to MATLAB.
.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

KSSV
KSSV 2021년 10월 11일

0 개 추천

syms theta(t)
f=cos(theta(t));
diff(f,t)

댓글 수: 1

Hamza Yusuf
Hamza Yusuf 2021년 10월 11일
I get this error:
Error using assignin
Invalid variable name "theta(t)" in ASSIGNIN.
Error in syms (line 47)
assignin('caller',varargin{1},sym(varargin{1}));
Error in test (line 1)
syms theta(t)

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

릴리스

R2020b

질문:

2021년 10월 11일

댓글:

2021년 10월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by