0

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
4

3 に答える 3

2

この行の代わりに「string1 = get(handles.edit1,'UserData');」

これを試してください string1 = get(handles.edit1,'String');

于 2013-10-17T04:27:21.880 に答える
1

で起こっている奇妙なことがたくさんありますpushbutton16_Callback

  • 'Visible','on'すべての編集ボックスの設定を維持する必要はありません
  • get 'String'アミール・ネマットが言ったように、そうではありません'UserData'
  • fullfileの代わりに使用strcat
  • 忘れないでfclose(fid)
  • あなたが戻っていcd './Images'ない限り、コールバックを実行しないでください。cdimread
  • imshow(A,'Parent',handles.axes4)代わりに行うaxes(handles.axes4); imshow(A);

また、GUI の名前を 以外の名前に変更することもできますuntitled2。;)

エラーが発生する理由については、よくわかりませんが、コールバックを実行gui_mainfcnしようとするとfevaluntitled2.m何か他のものが実行されているのではないかと思います。他のuntitled2MATLAB 実行可能ファイルを確認します: which -all untitled2.

于 2013-10-17T06:50:08.977 に答える
0

以下を使用するときに作業フォルダーを変更すると、問題が発生する可能性があります。

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
于 2013-11-14T08:10:41.150 に答える