-1

我在matlab中开发了GUI界面。当我按下一个按钮时,其他按钮不再起作用。例如,我运行了一个函数,如果我想打开一个文件,打开文件按钮不再起作用,并给我以下错误:当我运行 pushbutton16_Callback 时,pushbutton15_Callback 不再起作用。为什么 ?

Error in @(hObject,eventdata)untitled2('pushbutton15_Callback',hObject,eventdata,guidata(hObject)) 
Error while evaluating uicontrol Callback


function pushbutton15_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton15 (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({'*.*'},'Picture Selector');
fulpathname=strcat(pathname,filename);
set(handles.axes4,'Visible','On');
axes(handles.axes4)
imshow(fulpathname);
handles.pic=fulpathname;
info = imfinfo(fulpathname);
handles.format=info.Format;
guidata(hObject,handles);

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');
%cd ..;
fName=strcat(cd,'\Video Detail\Video Detail',string1);
%    fName=strcat(cd,'\Video Detail',(string1));
try
 fid = fopen(fName);
sizS = 10000;
lineCt = 1;
tline = fgetl(fid);
while ischar(tline)
s{lineCt} = tline;
lineCt = lineCt + 1;
%# grow s if necessary
if lineCt > sizS
   s = [s;cell(10000,1)];
   sizS = sizS + 10000;
end
tline = fgetl(fid);
end
%# remove empty entries in s
s(lineCt:end) = [];
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 'C:\Users\Dr Syed Abdul Rahman\Desktop\innovation final\Images';
cd './Images';
%str=strcat(string1);

A = imread('25');
axes(handles.axes4)
imshow(A);
%imshow('./video detail/1.jpg');
catch err
set(handles.text3,'Visible','On','String','File is not exist !') 
end
4

1 回答 1

1

我认为这是问题所在:

sizS = 10000;
lineCt = 1;
tline = fgetl(fid);
while ischar(tline)
  s{lineCt} = tline;
  lineCt = lineCt + 1;
  %# grow s if necessary
  if lineCt > sizS
     s = [s;cell(10000,1)];
     sizS = sizS + 10000;
  end
  tline = fgetl(fid);
end

这段代码很奇怪。while 循环触发了我,因为它是代码卡住的主要嫌疑人。

然后我看到你的代码没有多大意义。你先做fgetl(fid)10000次,然后你做sizS = sizS + 10000,然后你可能会重复这个?

无论您的 while 循环的内容如何,​​我都敢猜想ischar(tline)根本就不会满足停止条件。

于 2013-10-16T09:23:24.990 回答