How to returns to the current folder when i execut my gui?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Image Analyst
el 19 de Mayo de 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 comentarios
Image Analyst
el 19 de Mayo de 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));
Ver también
Categorías
Más información sobre Environment and Settings en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!