How can I make a symbolic function with vector input?

1 vue (au cours des 30 derniers jours)
Hansol Lee
Hansol Lee le 21 Avr 2020
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?

Réponse acceptée

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

Plus de réponses (0)

Catégories

En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!