How to modify a function handle?

20 visualizzazioni (ultimi 30 giorni)
Koki
Koki il 16 Mag 2021
Risposto: per isakson il 16 Mag 2021
Sorry I am not sure how to phrase the question but say I had a function handle say: myfun1 = @(y) y
Would I be able to modify that function and say something like myfun2 = @(y) myfun1*2
So when I write myfun2(5) it will return 10.
I essentially want to perform arithmetic on expressions representing functions of x to obtain other functions of x.

Risposta accettata

per isakson
per isakson il 16 Mag 2021
That's simpler than you thought
%%
f1 = @(y) y;
f2 = @(y) f1(y)*2;
%%
f2(5)
ans = 10

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by