在MatlabGUI中更新回调状态
我在MATLAB中开发了一个GUI界面。当我按下搜索按钮时,我看到了理想的结果。但是,当我更改文本框并再次按下搜索按钮时,它不起作用,并给出以下错误:在MatlabGUI中更新回调状态,matlab,user-interface,matlab-guide,Matlab,User Interface,Matlab Guide,我在MATLAB中开发了一个GUI界面。当我按下搜索按钮时,我看到了理想的结果。但是,当我更改文本框并再次按下搜索按钮时,它不起作用,并给出以下错误: Undefined function 'untitled2' for input arguments of type 'struct'. Error in @(hObject,eventdata)untitled2('edit1_Callback',hObject,eventdata,guidata(hObject)) Error whil
Undefined function 'untitled2' for input arguments of type 'struct'.
Error in @(hObject,eventdata)untitled2('edit1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
Undefined function 'untitled2' for input arguments of type 'struct'.
Error in @(hObject,eventdata)untitled2('pushbutton16_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
我必须重新执行所有代码!有没有办法重复运行GUI
如图所示,当我将视频ID更改为其他号码并按下搜索按钮时,结果不会更新
function pushbutton16_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton16 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%pathname='C:\Users\Dr Syed Abdul Rahman\Desktop\innovation final\video detail\';
string1 = get(handles.edit1,'UserData');
fName=strcat(cd,'\Video Detail\Video Detail',string1);
fid = fopen(fName);
if fid~=-1
s{1} = fgetl(fid);
s{2} = fgetl(fid);
s{3} = fgetl(fid);
s{4} = fgetl(fid);
s{5} = fgetl(fid);
s{6} = fgetl(fid);
s{7} = fgetl(fid);
set(handles.text4,'Visible','On');
set(handles.edit1,'Visible','On','String',s{1})
set(handles.edit2,'Visible','On','String',s{2})
set(handles.edit3,'Visible','On','String',s{3})
set(handles.edit4,'Visible','On','String',s{4})
set(handles.edit5,'Visible','On','String',s{5})
set(handles.edit6,'Visible','On','String',s{6})
set(handles.edit7,'Visible','On','String',s{7})
set(handles.axes4,'Visible','On');
cd './Images';
A = imread(s{1});
axes(handles.axes4)
imshow(A);
else
set(handles.text3,'Visible','On','String','File is not exist !')
end
而不是这行“string1=get(handles.edit1,'UserData')
试试这个
string1=get(handles.edit1,'String') 而不是这一行“string1=get(handles.edit1,'UserData')
试试这个
string1=get(handles.edit1,'String') 而不是这一行“string1=get(handles.edit1,'UserData')
试试这个
string1=get(handles.edit1,'String') 而不是这一行“string1=get(handles.edit1,'UserData')
试试这个
string1=get(handles.edit1,'String') 在
按钮16\u回调中发生了很多奇怪的事情:
- 您不需要为所有编辑框设置“可见”、“打开”
get
就像阿米尔·内马特所说的,而不是'UserData'
fullfile
而不是strcat
fclose(fid)
李>
cd./Images'
,除非返回cd
,但即使如此,也不是一个好主意,只需将imread
读入该路径即可imshow(A,'Parent',handles.axes4)
而不是轴(handles.axes4);imshow(A)代码>
untitled2
;)
至于为什么会出现错误,我不确定,但我怀疑当
gui_mainfcn
尝试feval
youruntiled2.m
运行回调时,它正在运行其他东西。检查其他untiled2
MATLAB可执行文件:其中-所有untiled2
在按钮16\u回调中发生了很多奇怪的事情
:
- 您不需要为所有编辑框设置“可见”、“打开”
get
就像阿米尔·内马特所说的,而不是'UserData'
- 使用
而不是fullfile
strcat
- 别忘了
李>fclose(fid)
- 不要在回调中执行
,除非返回cd./Images'
,但即使如此,也不是一个好主意,只需将cd
读入该路径即可imread
- 执行
而不是imshow(A,'Parent',handles.axes4)
轴(handles.axes4);imshow(A)代码>
untitled2
;)
至于为什么会出现错误,我不确定,但我怀疑当
gui_mainfcn
尝试feval
youruntiled2.m
运行回调时,它正在运行其他东西。检查其他untiled2
MATLAB可执行文件:其中-所有untiled2
在按钮16\u回调中发生了很多奇怪的事情
:
- 您不需要为所有编辑框设置“可见”、“打开”
get
就像阿米尔·内马特所说的,而不是'UserData'
- 使用
而不是fullfile
strcat
- 别忘了
李>fclose(fid)
- 不要在回调中执行
,除非返回cd./Images'
,但即使如此,也不是一个好主意,只需将cd
读入该路径即可imread
- 执行
而不是imshow(A,'Parent',handles.axes4)
轴(handles.axes4);imshow(A)代码>
untitled2
;)
至于为什么会出现错误,我不确定,但我怀疑当
gui_mainfcn
尝试feval
youruntiled2.m
运行回调时,它正在运行其他东西。检查其他untiled2
MATLAB可执行文件:其中-所有untiled2
在按钮16\u回调中发生了很多奇怪的事情
:
- 您不需要为所有编辑框设置“可见”、“打开”
get
就像阿米尔·内马特所说的,而不是'UserData'
- 使用
而不是fullfile
strcat
- 别忘了
李>fclose(fid)
- 不要在回调中执行
,除非返回cd./Images'
,但即使如此,也不是一个好主意,只需将cd
读入该路径即可imread
- 执行
而不是imshow(A,'Parent',handles.axes4)
轴(handles.axes4);imshow(A)代码>
untitled2
;)
至于为什么会出现错误,我不确定,但我怀疑当
gui_mainfcn
尝试feval
youruntiled2.m
运行回调时,它正在运行其他东西。检查其他untitled2
MATLAB可执行文件:其中-所有untitled2
当您使用以下文件时,可能会出现更改工作文件夹的问题:
cd './Images';
一个可能的修正可以是:
oldPath = cd('./Images'); % Return the path that you were before
A = imread(s{1});
axes(handles.axes4)
imshow(A);
cd(oldPath); % Go back in the folder with all your functions
您可能会遇到以下问题,即在使用时更改了工作文件夹:
cd './Images';
一个可能的修正可以是:
oldPath = cd('./Images'); % Return the path that you were before
A = imread(s{1});
axes(handles.axes4)
imshow(A);
cd(oldPath); % Go back in the folder with all your functions
您可能会遇到以下问题,即在使用时更改了工作文件夹:
cd './Images';
一个可能的修正可以是:
oldPath = cd('./Images'); % Return the path that you were before
A = imread(s{1});
axes(handles.axes4)
imshow(A);
cd(oldPath); % Go back in the folder with all your functions
您可能会遇到以下问题,即在使用时更改了工作文件夹:
cd './Images';
一个可能的修正可以是:
oldPath = cd('./Images'); % Return the path that you were before
A = imread(s{1});
axes(handles.axes4)
imshow(A);
cd(oldPath); % Go back in the folder with all your functions
untitled2
的声明如下:函数varargout=untitled2(varargin)
?应该是t