How to create a dynamic function handle?
6 次查看(过去 30 天)
显示 更早的评论
I want to create a dynamic function handle. How to do?
1 个评论
John D'Errico
2022-11-22
What is a dynamic function handle? If you want a useful answer, you need to ask a clear question.
回答(1 个)
Star Strider
2022-11-22
I have no idea what you are asking.
It is straightforward to create a function handle that accepts various function arguments, either for a specific function or an existing function.
f = @(x,y) exp(-(x.^2 + y.^2)/5);
[X,Y] = ndgrid(-5:0.1:5);
figure
surf(X, Y, f(X,Y))
grid on
.
2 个评论
Star Strider
2022-11-22
Create the functions you want, then use an if, elseif, else block to choose the function to execute with respect to a particular condition.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!