How can I find out the first execution of the function?
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Samir Gautam
am 29 Dez. 2016
Beantwortet: Walter Roberson
am 29 Dez. 2016
In a program I need to use some values for only during the first execution of the function, thereafter the execution of the function will have to take the updated values. Is there anyway I can find the execution number from Matlab command?
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 29 Dez. 2016
Add this to the beginning of the code:
persistent number_of_executions
if isempty(number_of_executions); number_of_executions = 0; end
number_of_executions = number_of_executions + 1;
Now you can test if number_of_executions == 1
0 Kommentare
Weitere Antworten (1)
adi kul
am 29 Dez. 2016
Well, your requirements are not clear. What I understood is, you have a script which calls different function files and you want to know which one executes 1st.
Considering this is your requirement, what I would suggest is, check the function file names from the folder of your script which will be in .m format and now in your script try to find the exact name amongst them. The functions are called in script by their file name hence 1st of them will be the 1st getting executed.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Get Started with MATLAB 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!