How to returns to the current folder when i execut my gui?
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello everybody, I have a problem with my gui. All the figs and functions are saved in a defined directory. If I execute the GUI and then i change the current folder since the matlab editor the GUI does not works. Are there any solution to return to the current folder where my gui is saved?
I try to use cd, but when i run the GUI and i change the current folder, where it is saved, it does not work.
0 Commenti
Risposte (1)
Image Analyst
il 19 Mag 2018
Simply keep track of the known folder, like in a field of handles, like handles.dataFolder. Then when you want to do anything with any files, put the base filename into full file and read it in:
fullFileName = fullfile(handles.dataFolder, 'whatever.dat');
You shouldn't need to know the folder where your program is. But if you really do, and you have Windows, see the attached function.
2 Commenti
Image Analyst
il 19 Mag 2018
So it has nothing to do with the folder and everything to do with some function or variable called Welcome not being defined. It's evidently in a different folder than your main program and you do not have a path set to it. You can add a path either with the Set Path tool on the tool ribbon, or in your OpeningFcn of your GUI code with this code:
folder = 'C:\Users\Abel\Documents\MATLAB\TFG_definitivo2';
% Add all functions in that folder and subfolders of it to the search path so it will find the functions.
addpath(genpath(folder));
Vedere anche
Categorie
Scopri di più su Environment and Settings 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!