Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在MatlabGUI中更新回调状态_Matlab_User Interface_Matlab Guide - Fatal编程技术网

在MatlabGUI中更新回调状态

在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

我在MATLAB中开发了一个GUI界面。当我按下搜索按钮时,我看到了理想的结果。但是,当我更改文本框并再次按下搜索按钮时,它不起作用,并给出以下错误:

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)
  • 此外,您可能希望将GUI重命名为非
    untitled2
    ;)


    至于为什么会出现错误,我不确定,但我怀疑当
    gui_mainfcn
    尝试
    feval
    your
    untiled2.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)
    此外,您可能希望将GUI重命名为非
    untitled2
    ;)


    至于为什么会出现错误,我不确定,但我怀疑当
    gui_mainfcn
    尝试
    feval
    your
    untiled2.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)
    此外,您可能希望将GUI重命名为非
    untitled2
    ;)


    至于为什么会出现错误,我不确定,但我怀疑当
    gui_mainfcn
    尝试
    feval
    your
    untiled2.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)
    此外,您可能希望将GUI重命名为非
    untitled2
    ;)


    至于为什么会出现错误,我不确定,但我怀疑当
    gui_mainfcn
    尝试
    feval
    your
    untiled2.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