Rename function inside MATLAB script
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Daniel Moreno
am 21 Sep. 2017
Bearbeitet: James Tursa
am 21 Sep. 2017
I have one generic script that calls in several times a function, which I want to be changing the name in an easy way. My idea would be to change the name of the variable in the upper part of the script and that it directly changes in all the script. The structure of my idea would be the following:
FunctionName = 'newName';
[...code...]
@(data,h)FunctionName(data,h)
[...code...]
How would that be possible?
Many thanks
0 Kommentare
Akzeptierte Antwort
James Tursa
am 21 Sep. 2017
Bearbeitet: James Tursa
am 21 Sep. 2017
One way assuming your input is a string:
FunctionName = 'newName';
:
FunctionHandle = str2func(FunctionName);
f = @(data,h)FunctionHandle(data,h);
Or, if you want to use function handles from the start:
FunctionName = @newName;
:
f = @(data,h)FunctionName(data,h);
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Variables finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!