Problem of Symbolic function evaluation

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.

 채택된 답변

Torsten
Torsten 2022년 10월 13일
u = sym('u',[2 1]);
f = u.'*u
f = 
result = subs(f,u,[1;2])
result = 
5

댓글 수: 1

Morty
Morty 2022년 10월 13일
Thank you very much for your answer! I have been confused about this problem for some days.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

제품

릴리스

R2022b

태그

질문:

2022년 10월 13일

댓글:

2022년 10월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by