Evaluating symbolic function with a vector
Mostra commenti meno recenti
I know this has been asked before, but none of the answers I've found have been helpful.
Here's the simple example of what I'm trying to do:
syms x1 x2
f(x1,x2) = x1 + x2;
x = [ 1 1];
f(x)
I would expect this to return:
ans =
2
Which, of course, is not working, as seen in the error stated above.
Any insights on how can I define a function that accepts a vector of values for many variables?
Risposta accettata
Più risposte (1)
% take x1 and x2 as two variables
syms x1 x2
f(x1,x2) = x1 + x2;
x = [ 1 1];
f(x(1), x(2))
Categorie
Scopri di più su Operations on Strings in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!