Intermediate calculation in function handle
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
StarBucK
am 31 Okt. 2018
Kommentiert: StarBucK
am 1 Nov. 2018
Hi
I would like to know if it is possible to make intermediate calculation in a function handle.
For example, making something like this functional :
@(x) y=1+1; x+y;
This function handle would return me 3 for example for x=1. y is thus an intermediate variable of a calculation inside the function handle.
Is there a way to do it ?
Thanks
0 Kommentare
Akzeptierte Antwort
the cyclist
am 31 Okt. 2018
I don't really understand what you want to do. I'm guessing you deliberately chose the simplest possible example, and that what you really want to do is more complicated. But since your example is trivially
@(x) x + 2
I can't quite get what you really need.
Maybe you mean something like this?
y = @(z) z + 1; % The intermediate function?
f = @(x,g) x + g; % The final function
f(1,y(1)) % Calling syntax
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!