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!

 Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 25 Juin 2016
Modifié(e) : Azzi Abdelmalek le 25 Juin 2016

0 votes

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

2 commentaires

Goldy
Goldy le 25 Juin 2016
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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Symbolic Math Toolbox dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by