필터 지우기
필터 지우기

The cause of 'Error while evaluating uicontrol Callback' in GUI window

조회 수: 3 (최근 30일)
Aaron Smith
Aaron Smith 2017년 5월 24일
댓글: Jan 2020년 12월 18일
I have encountered this error in running a GUI window that I have created. From what I have been able to discern online, it is caused by a problem with the handle structure but the piece of code that continues to be identified by matlab as the problem is this:
Error in new_window_2>pushbutton1_Callback (line 190)
set(handles.verticalBin, 'enable', 'on');
I have changed a number of lines in the code but i am not sure how this (or other set(handles, 'enable', '') statements) are causing an error. How might the handles structure be failing to work properly to generate this error?
  댓글 수: 2
Jan
Jan 2017년 5월 24일
The handle struct is not the problem. Please post the complete error message. Currently we see only the part, which defines where the problem is, but not what.
Stephen23
Stephen23 2017년 5월 25일
Good code does not use globals: "I have never seen MATLAB code where globals were the right thing to do.... Most of the time I have seen globals being used it was a situation where the code author did not understand scoping of variables. Rather than pass variables from one function to another, they were just being made global."
Note that using globals is a programming practice that will make your code very hard to debug. Passing arguments is much more robust, and is the recommended way of passing data between workspaces:

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

채택된 답변

Jan
Jan 2017년 5월 24일
Using globals is a really bad idea. This impedes the debugging, because you cannot find reliable, which code is resposnible for the last change. Do not use such an indirect method, but the handles struct, which is used for sharing other details already.
It is not clear, where the object of the handle handles.verticalBin is created. Are you sure that this field is existing in the handles struct?
  댓글 수: 11
Aaron Smith
Aaron Smith 2017년 5월 26일
I was from when I first started off learning basic calculations using notation such as ==, =>, etc. I may have carried it over from here or simply misunderstood the operators when beginning
Adam
Adam 2017년 5월 30일
It can be difficult with some of these operators because as a beginner (sometimes as a more experienced user too) it can be hard to know what to type in the help to get to the right documentation page. Searching for just '=' or '==' does not yield anything so it is useful to know the function name equivalents to search e.g.
doc eq
The assignment operator is a tricky one though, I'm not aware it has a function-based equivalent given its nature and I must admit I gave up trying to work out where in the help it is introduced and defined. I'm sure it is somewhere linked from the Matlab introductory pages, but I didn't find it. Thankfully I know how it works so I don't need to find it on this occasion!

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

추가 답변 (1개)

mohammadreza mahmoudi
mohammadreza mahmoudi 2020년 12월 18일
편집: mohammadreza mahmoudi 2020년 12월 18일
hi dear friends and professors.
how can i solve this problem?
Error: label vector and instance matrix must be double
Unable to perform assignment because the indices on the left side are not compatible with the size of the rightn side.
Error in main>multisvm (line 991)
models(k) = svmtrain(TrainingSet,G1vAll);
Error in main>pushbutton14_Callback (line 866)
result = multisvm(data_feat,data_label,test_data);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in main (line 18)
gui_mainfcn(gui_State, varargin{:});
Errorin matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)main('pushbutton14_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.
  댓글 수: 1
Jan
Jan 2020년 12월 18일
Please open a new thread to ask a new question. This is the section for answers to another question.

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

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by