How to input a vector into a multi-variable symbolic function - Error using symfun/subsref
古いコメントを表示
Hi,
I'm trying to generate a series of vectors using a recursive function. Say my initial vector is [1 1], and my function is f((x,y))=(x+1,y+2).
I've defined my function as follows:
syms x y;
f=symfun([x+1 y+2],[x y]);
I then want to apply f to the initial vector, but when I try to use
f([1 1])
I get the error
Error using symfun/subsref
Symbolic function expected 2 inputs and received 1.
How can I apply f to this vector? The issue is that the vector's dimensions vary, so I can't explicitly write
f(x1, x2, ... xn)
Thanks in advance!
回答 (1 件)
Mert Haciahmetoglu
2020 年 4 月 18 日
0 投票
okay it's a bit late but maybe someone else could use this
try this:
subs(symbolic_expression, list_of_variables, list_of_values)
カテゴリ
ヘルプ センター および File Exchange で Programming についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!