How to returns to the current folder when i execut my gui?
4 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Image Analyst
2018 年 5 月 19 日
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 件のコメント
Image Analyst
2018 年 5 月 19 日
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));
参考
カテゴリ
Help Center および File Exchange で Environment and Settings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!