How to replace variable name in function handle?
이전 댓글 표시
I have a function handle as given below
f = @(x1,x2) x1*x2
and I want to change variable name to
f = @(x) x(1)*x(2)
Please help me
Thanks
PS: The function is just for illustration purpose
댓글 수: 1
Marco Aurélio
2024년 7월 9일
Hello Matlab mate.
I think you must redefine de function handle just rewriting like this:
f=@(x) prod(x);
채택된 답변
추가 답변 (1개)
madhan ravi
2019년 2월 25일
Instead of converting it to your later need convert the vector as comma separated list using num2cell():
x=rand(1,2); % example vector
X=num2cell(x);
f(X{:}) % pass the vector all at once
카테고리
도움말 센터 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!