How to create a dynamic function handle?

11 views (last 30 days)
Marianna
Marianna on 22 Nov 2022
Commented: John D'Errico on 22 Nov 2022
I want to create a dynamic function handle. How to do?

Answers (1)

Star Strider
Star Strider on 22 Nov 2022
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 Comments
Star Strider
Star Strider on 22 Nov 2022
Create the functions you want, then use an if, elseif, else block to choose the function to execute with respect to a particular condition.

Sign in to comment.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!