在MatLab GUI中浏览目录

时间:2013-07-23 13:33:33

标签: matlab user-interface

我是Matlab的新手,基本上我要做的是创建一个GUI,让用户浏览他们想要打开的文件,并将字符串放在浏览按钮旁边的编辑框中。

到目前为止,我的代码对于浏览按钮

看起来像这样
 function Select_Callback(hObject, eventdata, handles)
% hObject    handle to Select (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
[filename,pathname]=uigetfile(...
{'*.csv';'*.xls';'*.xlsx'; '*.*';},'Select the Run Summaries File');
handles.filename=filename;
handles.pathname=pathname;



guidata(hObject,handles);
set(handles.RunSum,'String',[pathname filename]);
set(handles.Brows,'String',pathname);

RunSum是旁边的编辑框的标记。到目前为止,当我运行.m文件并且编辑框在选择文件时成功更改其字符串时,GUI工作正常,但是,当我从.fig文件运行GUI并浏览文件时,我不断得到这个错误:

Reference to non-existent field 'RunSum'.

Error in ID_analysis>Select_Callback (line 383)
set(handles.RunSum,'String',[pathname filename]);

Error in gui_mainfcn (line 96)
    feval(varargin{:});

Error in ID_analysis (line 42)
gui_mainfcn(gui_State, varargin{:});

Error in @(hObject,eventdata)ID_analysis('Select_Callback',hObject,eventdata,guidata(hObject))


Error while evaluating uicontrol Callback

它提到了对一个不存在的字段的引用,但在脚本中它存在并存在。有没有其他更好的方法来制作这个浏览按钮?我不明白为什么.fig文件无法检测到编辑标签'RunSum'?

0 个答案:

没有答案