Azzera filtri
Azzera filtri

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

4 visualizzazioni (ultimi 30 giorni)
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 Commenti
Jan il 24 Mag 2017
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 il 25 Mag 2017
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:

Accedi per commentare.

Risposta accettata

Jan il 24 Mag 2017
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 Commenti
Aaron Smith
Aaron Smith il 26 Mag 2017
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 il 30 Mag 2017
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!

Accedi per commentare.

Più risposte (1)

mohammadreza mahmoudi
mohammadreza mahmoudi il 18 Dic 2020
Modificato: mohammadreza mahmoudi il 18 Dic 2020
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)
Error in main (line 18)
gui_mainfcn(gui_State, varargin{:});
Error while evaluating UIControl Callback.
  1 Commento
Jan il 18 Dic 2020
Please open a new thread to ask a new question. This is the section for answers to another question.

Accedi per commentare.


Scopri di più su Environment and Settings in Help Center e File Exchange


Community Treasure Hunt

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

Start Hunting!

Translated by