Evaluating symbolic function with a vector
Afficher commentaires plus anciens
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?
Réponse acceptée
Plus de réponses (1)
% take x1 and x2 as two variables
syms x1 x2
f(x1,x2) = x1 + x2;
x = [ 1 1];
f(x(1), x(2))
Catégories
En savoir plus sur Operations on Strings dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!