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!