How can I make a symbolic function with vector input?

3 次查看(过去 30 天)
I want to make a symbolic function with vector input.
I tried a code
a=sym('a',[1 3]);
f(a)=a(1)^2+a(2)+a(3)*a(1);
k=[1 1 1];
f(k)
But it didn't work. I could find that f(1,1,1) works, but I want to make f with f([1 1 1]). How could I do it?

采纳的回答

Jyotsna Talluri
Jyotsna Talluri 2020-4-24
a=sym('a',[1 3]);
f= @(a)(a(1)^2+a(2)+a(3)*a(1));
k=[1 1 1];
f(k)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!