Evaluating symbolic function with a vector
古いコメントを表示
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?
採用された回答
その他の回答 (1 件)
% take x1 and x2 as two variables
syms x1 x2
f(x1,x2) = x1 + x2;
x = [ 1 1];
f(x(1), x(2))
カテゴリ
ヘルプ センター および File Exchange で Operations on Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!