Hi everyone,
I can find the partial derivative of a function using syms:
syms x , d
f = ... % a complicated function of x and d
df = diff(f,d)
I would like now to use x and d as variables in a for loop to calculate df for specific values of x and d. How is this possible? Thank you!

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2016년 6월 25일
편집: Azzi Abdelmalek 2016년 6월 25일

0 개 추천

syms x d
f = x*sin(d)
df=diff(f,d)
d1=pi
x1=5
out=subs(df,[d x],[d1 x1])

댓글 수: 2

great! thank you! well, what if I want to do something like this:
for x=0:0.1:5
for d=0:20
...
end
end
What would I put instead of
d1=pi
x1=5
out=subs(df,[d x],[d1 x1])
?
k=0;
for x1=0:0.1:5
for d1=0:20
k=k+1;
out(k)=subs(df,[d x],[d1 x1])
end
end

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

태그

질문:

2016년 6월 25일

댓글:

2016년 6월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by