convert symbols to variables

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!

 Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 25 de Jun. de 2016
Editada: Azzi Abdelmalek el 25 de Jun. de 2016

0 votos

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

2 comentarios

Goldy
Goldy el 25 de Jun. de 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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Symbolic Math Toolbox en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 25 de Jun. de 2016

Comentada:

el 25 de Jun. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by