force matlab to display its symbolic calculations using indexed varaiables
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
hosein Javan
el 11 de En. de 2017
Comentada: Walter Roberson
el 12 de En. de 2017
hello. I'm looking for a way to make matlab display the result of its output by showing the variables with their index, while doing symbolic calculations. for example in this code I want it to display x(1) instead of x1.
x=sym('x',[1 2])
y=x(1)*x(2)
e=diff(y,x(2))
now here's matlab results:
ans=
x1
what matlab did here, was to show what's contained in x(1) which is x1. the reason why I'm trying to do this, is that I need these results to create a function whose input is an indexed variable to use with fsolve because this function requires x(1), x(2) and not x1, x2. I know it is possible using strings and eval function but I need a better way.
0 comentarios
Respuesta aceptada
Walter Roberson
el 12 de En. de 2017
x = sym('x',[1 2])
y = x(2)^2 + sin(x(1)*x(2));
e = diff(y, x(2))
f = matlabFunction(y, 'vars', {x});
fsolve(f, rand(1,2))
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!