Passing a vector of values through a symbolic function

8 visualizaciones (últimos 30 días)
Billy Worley
Billy Worley el 2 de Nov. de 2019
Respondida: Walter Roberson el 3 de Nov. de 2019
How do I assign values from a vector to a symbolic function? I have a functin of multiple variables x1,x2,x3,etc. and a vector X, that has initial values of 0.
I'm having trouble coming up with a vector that if I were to input x1 in the command window, it will display x1 = 0.
Example with a known set of variables:
A = sym('x', [1 5])
F = cos(A(1)) + sin(A(2)) + (A(3))^3 + 5*A(4) - cos(A(5))
** If I run this, it will say :
F = x3^3 + 5*x4 + cos(x1) - cos(x5) + sin(x2)
So how can I create a vector that will replace values of x1, x2, x3, x4, and x5 into the equation? I know in a general sense, if I actually write out x1 = 0, x2 = 0, etc. it will calculate the values, but in a general sense when I do not know how many x1, x2, etc. there will be, I have to have it in vector form to where it will take those values from the vector and plug them in.

Respuestas (1)

Walter Roberson
Walter Roberson el 3 de Nov. de 2019
subs(F, A, vector)

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by