Matlab function that tells the full path of from where the function has been called
Mostra commenti meno recenti
Not sure the title is very clear so I'll describe my project :
There is this class 1 in Desktop/Folder/Sub_Folder1/@class1/class1.m in which a function1 is coded.
There is this class 2 in Desktop/Folder/Sub_Folder2/@class2/class2.m in which a function 2 is coded.
When function2 is called, it calls function1 that displays a message. There will be in the future function3, 4, 5.. that will also call function1 and display a message so I want to know in the message what function triggered function1.
I tried dbstack but it doesn't give me the whole path. only 'class2.function2'
Also, for some reason I'm in matlab2014a.
Risposte (2)
What about passing the full path where the function is located from the respective functions 2,3,4,5... to function1 ?
See
together with fileparts() to extract the directory portion, and fullfile() to construct the new file name.
Walter Roberson
il 7 Apr 2025
0 voti
Categorie
Scopri di più su Variables in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!