Anonymous function arguments and parameters extrction
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
If I have the anonymous function:
pu = @(x, y) [x,y];
is it npossible to extract the value of the argument x after the function has acted on it?
(Apologies if this does not make sense)
0 Commenti
Risposte (2)
Steven Lord
il 1 Apr 2022
As written, as long as you know how long either one of the inputs was, yes.
P = @(x, y) [x, y];
x1 = 1:5;
y1 = 6:10;
z = P(x1, y1)
x2 = z(1:5); % I know how long x was, extract that many elements from z
isequal(x2, x1)
x3 = z;
x3(end-4:end) = []; % I know how long y was, remove that many elements from z
isequal(x3, x1)
0 Commenti
Jan
il 1 Apr 2022
pu = @(x, y) [x,y];
a = pu(1, 2:3)
b = pu(1:2, 3)
isequal(a, b)
This means: No, you cannot decide, what the inputs have been based on the output.
0 Commenti
Vedere anche
Categorie
Scopri di più su Interpolation 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!