Problem of Symbolic function evaluation

2 vues (au cours des 30 derniers jours)
Morty
Morty le 13 Oct 2022
Commenté : Morty le 13 Oct 2022
syms u [2 1]
f(u) = u'*u;
f(1,2) % Correct syntax the ans is 5
f([1;2]) %Incorrect syntax Symbolic function expected 2 input arguments but received 1.
Why can the input of a function only be two variables, not a vector? What if there are many variables, such as 100 variables? It is too troublesome to input 100 values one by one during evaluation.

Réponse acceptée

Torsten
Torsten le 13 Oct 2022
u = sym('u',[2 1]);
f = u.'*u
f = 
result = subs(f,u,[1;2])
result = 
5
  1 commentaire
Morty
Morty le 13 Oct 2022
Thank you very much for your answer! I have been confused about this problem for some days.

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by