Gui, m.file works but fig doesn't

조회 수: 1 (최근 30일)
tian
tian 2013년 7월 24일
hi everyone:
I have this small gui right now, what confuses me is that I can run the gui perfectly by running the m.file, But it does't work if I directly open up the fig. file , plz help.
here is the error description:
Attempt to reference field of non-structure array.
Error in KMeans>numbers_Callback (line 84)
C=str2num(get(handles.edit1, 'String'));
-----------------------------------------------------------
here is the code at line 84:
function numbers_Callback(hObject, eventdata, handles)
% hObject handle to numbers (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
A=[uiimport];
B=getfield(A, 'data');
C=str2num(get(handles.edit1, 'String')); this is line 84
N=kmeans(B, C);
F=num2str(N);
set(handles.results, 'String', F);
  댓글 수: 1
nl2605
nl2605 2013년 7월 25일
I thought it must be just a problem in your GUI but now I tried the same with a program of mine and it gives the same error. Although it doesn't when running the m file.

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

답변 (2개)

nl2605
nl2605 2013년 7월 25일
This question has been asked before. http://www.mathworks.de/matlabcentral/answers/56203 this helped me in understanding the problem. Hope it helps you too.

David Sanchez
David Sanchez 2013년 7월 25일
The .fig file of the GUI holds the graphical objects of the GUI, it is not destined to be run. To run the GUI you ALWAYS have to run the associated .m file.
  댓글 수: 1
nl2605
nl2605 2013년 7월 25일
Yes, but doesn't the opening func run everytime when we open the fig file too?

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

카테고리

Help CenterFile Exchange에서 Entering Commands에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by