uigetdir in a gui environment
12 ビュー (過去 30 日間)
古いコメントを表示
i'm preparing a gui that consist in three buttons, two of these buttons select two directories and the third one save the paths in .mat file
i've been trying for hours to fix the script, but i have no experience in matlab gui's..... the idea is to obtain the paths and put these path into a .mat file (called terracem_path.mat).
until now this is what i get:
%%button 1 (maindir)
% --- Executes on button press in maindir.
function maindir_Callback(hObject, eventdata, handles)
% hObject handle to maindir (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Retrieve GUI data (the handles structure)
handles = guidata(hObject)
dir1=uigetdir(pwd,'Set the path to script files')
handles.maindir=char(dir1);
% Update handles structure
guidata(hObject, handles);
%%button 2 (stationsdir)
% --- Executes on button press in stationsdir.
function stationsdir_Callback(hObject, eventdata, handles)
% hObject handle to stationsdir (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles = guidata(hObject)
dir2=uigetdir(pwd,'Set folder with stations files')
handles.stationsdir=char(dir2);
% Update handles structure
guidata(hObject, handles);
%%button 3 (pushbutton5)
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%addpath(handles.maindir)
msgbox('Station dir path defined')
structdata=struct('terracem_dir','handles.maindir','stationsdir','handles.stationdir');
save('terracem_path.mat','structdata')
the pop ups windows are executing well, and opens and let me select the directories, however i can not save the paths of the directories in the final .mat file......
please if somebody have an idea will be really appreciated... i`m stuck in this issue since hours....
cheers
0 件のコメント
採用された回答
Walter Roberson
2013 年 5 月 4 日
structdata = struct('terracem_dir', handles.maindir, 'stationsdir', handles.stationdir);
Question: Do you want the information saved as a structure, or do you want the information saved as the separate variables 'terracem_dir" and 'stationsdir' ? If you want separate variables then use
save('terracem_path.mat', 'structdata', '-struct')
3 件のコメント
Walter Roberson
2013 年 5 月 4 日
Sorry, the syntax is different than most other options.
save('terracem_path.mat', '-struct', 'structdata')
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Startup and Shutdown についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!