Help urgent ! Error while evaluating uicontrol Callback
181 views (last 30 days)
Walter Roberson on 28 May 2017
Your code relies upon Legacy Arduino, suitable for MATLAB R2011a to R2013b only. It calls upon install_arduino which is defined by that particular support package, and it uses pinMode(), which was replaced, as I discuss in https://www.mathworks.com/matlabcentral/answers/304583-no-appropriate-method-property-or-field-pinmode-for-class-arduino#answer_236196
Your code is not suitable for demonstrating any reasonably current version of MATLAB: it will fail for R2014a or later.
In the version range that it works for, your code would crash at the location it does if you have not first clicked on the STABILESTE CONEXIUENEA button to initialize the arduino connection. Your code will also have problems if you do not click on START as well.
Your code will fail when you click on START if you are not using a PC, as the code expects to be able to access the winvideo video adapter.
More Answers (2)
Guillaume on 25 May 2017
Edited: Guillaume on 25 May 2017
As per Stephen's comment, you have a bug with your global variables. Either, your callback is being executed before whichever function is supposed to set a to the correct value had a chance to do so, or some function has changed the global a to an invalid value. Either way, when the callback is executed a is not yet/no longer a structure and you get your error.
As Stephen said, globals are a bad idea, precisely for this reason. It's very difficult to track what happens to them; any function can modify their value. It's also difficult to make sure that they're initialised in the right order, particularly when you use asynchronous functions such as callback.
You now have two options:
- go over the whole of your program and check the flow to see when a is supposed to be set to the correct value (can be anywhere in the code), see where it is being changed (again can be anywhere) and make sure that this always happen before there's a chance your callback is called.
- radically modify your code to use recommended practices such as gui handles
Neither is going to be quick. The second approach would ultimately serve you better.
Oh, and by the way: why-your-question-is-not-urgent-or-an-emergency
ismail tas on 9 May 2020
ı have similer problem in Matlab Gui . I want to desing calculator. Every toggle button dont have any problem but answer button have problem and it gives Error while evaluating UIControl Callback.