Passing a vector of values through a symbolic function

11 views (last 30 days)
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.

Answers (1)

Walter Roberson
Walter Roberson on 3 Nov 2019
subs(F, A, vector)

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!