필터 지우기
필터 지우기

How to load a .mat file with a push button in matlab GUI

조회 수: 1 (최근 30일)
Deepa AS
Deepa AS 2015년 7월 27일
편집: Deepa AS 2015년 7월 27일
I tried this code,
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (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('*.mat','Select mat file');
if FileName==0, return, end
Struct1 = load( fullfile(PathName,FileName) ); %# pass file path as string
Structname = fieldnames(Struct1);
end%# typo?
But its showing the following error:
Error using feval
Undefined function 'pushbutton1_Callback' for input arguments of type 'struct'.
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in compgui (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)compgui('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
Can anybody please help me out with this
Thank you
Deepa

채택된 답변

Walter Roberson
Walter Roberson 2015년 7월 27일
편집: Walter Roberson 2015년 7월 27일
You defined pushbutton2_Callback but your pushbutton is configured to expect pushbutton1_Callback
After you load() the data you will probably need to store it:
  댓글 수: 1
Deepa AS
Deepa AS 2015년 7월 27일
편집: Deepa AS 2015년 7월 27일
Thank you sir. A helpful link. But I sorted that problem by changing the size of user data in property inspector to a value of my .mat file.The error was rectified.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by