-1

私はmatlabでGUIインターフェースを開発しました。ボタンを押すと、他のボタンが機能しなくなりました。たとえば、関数を実行しましたが、ファイルを開こうとすると、ファイルを開くボタンが機能しなくなり、次のエラーが表示されます。なぜ ?

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 に答える