Problem with Udemy tutorial: getting 'Error while evaluating UIControl Callback.' - user-interface

I am going through the Udemy course "Learn image processing and GUIs while having fun in MATLAB". I'm trying to create the GUI to plot lines of random numbers. I'm troubleshooting this bit of code:
`% --- Executes on button press in MakeThePlot.
function MakeThePlot_Callback(hObject, eventdata, handles)
numCol = str2double( get(handles.numLines,'string') );
disp('A')
There is a dot next to the last line indicating (I guess) that I'm only working with the MakeThePlot function. If I do NOT have the line beginning with "numCol" in the file, it runs perfectly, displaying A in the console every time I hit the "MakeThePlot' button in the GUI. Add in the one line, and it throws the error I give in the title. AFAIK I'm following the instructor's steps exactly. What am I doing wrong? THanks in advance.
I'm not sure what to add to what I gave above. I tried putting in only one line of the instructor's code in the function to keep it simple. I expected it to do nothing but display 'A' in the console.

Related

How to diagnose Xcode errors

I have been using Xcode recently a lot, however, every so often I'll inexplicably receive error messages about perfectly innocuous components of my code. I'd like to know how one diagnose these because as you can see in the buttom right of the screenshot, there's no log entry to go off of. Thanks.
Here's my screen shot:
It looks as if you have accidentally set a "breakpoint" in your code. You set a breakpoint by clicking on the left margin. A breakpoint stops your code automatically when it reaches that point.
Since you commented out the inside of the goBack() function, it stops at the first line of uncommented code.
The breakpoint you set is the little blue line to the left of the line self.scoreLabel.removeFromSuperview(). To get rid of it, click it and drag it into the main area of your code.

Matlab GUI Attempt to reference field of non-structure array

I have a GUI menu on Matlab with 4 buttons (menu.fig). Then I have 4 .fig file that I want to open when I click on the buttons. Here it's all ok, when I open a .fig from menu and insert value to do a plot I get this error:
???? Attempt to reference field of non-structure array.
If I try to open 1.fig directly, everything works perfectly.
I read that the problem is with eval(), but I can't solve it.
I changed the variable names on each .fig file
One 1.fig:
function pbutton1_Callback(hObject, eventdata, handles)
A1=get(handles.edtSAmp,'String');
f1=get(handles.edtSFreq, 'String');
fi1=get(handles.edtSFase, 'String');
t1=get(handles.popTipo, 'Value');
A1=str2double(A1);
f1=str2double(f1);
fi=str2double(fi1);
SinalSinusoidal(A1,f1,fi,t1);
I got the error on the that 1st line.
I guess this is something MATLAB GUI not handled well. I know it used to work, but when you tweaking your UI or UI related code a bit and accidentally you modified some area MATLAB told you not to touch, this kind of issue begin to happen.
The workaournd is to start the GUI from M editor by clicking run
I know it works, but originally, when I directly lauch it , it works too. so, this is not the end of it, people are just not getting to the end of it.
The problem is with probably with handles1. It's not a structure array like you expect it to be. In GUI's created with GUIDE, this variable is usually called handles, if you have both handles and handles1 make sure handles1 contains handles to the objects in the figure. If you're using handles1 only, make sure you're initializing it properly.

How to remove splash screen?

Right, hi guys, I recently followed a tutorial http://xnadevelopment.com/tutorials/thestateofthings/thestateofthings.shtml where I wanted to create a sort of splash screen, and it worked I managed to get a two different screens interchanging between one another (so, if I press A, it goes to TitleScreen, and if I press B, it returns back to ControllerDetectScreen)
Here's the code http://paste.org/43859
Obviously there is no actual game, but if you could show me how to get rid of the TitleScreen and ControllerDetectScreen by adding a function to remove them both out of the way (preferably the spacebar, and to start my game (The background will be 'CornFlowerBlue after the function is added and pressed.)
Thank you!
Using the same code, you could add another bool for whether you're in the game or not, and another if statement wherever you need it to contain the code for the game (probably Update and Draw)

Matlab GUI gives error, but m file okaz

I`m absolutely new in Matlab, so I think it is a dumb question, but I would be really grateful for any help.
I had made a GUI with some slider. When I compile the m file everything works fine, there are no exceptions and the program do what it have to, but when I click on the fig file directly and try to move one of the sliders I got the following error:
??? Undefined function or method 'diference_GUI' for input arguments of type 'char'.
Error in ==>#(hObject,eventdata)diference_GUI('slider1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
I had found some forum, blog article in this topic, but I want able to solve. Try-Catch not good, because if I do it, I dont get any error message, but the program still don`t do what it need.
Thank you for your help, Karoly
Your question isn't quite clear, but I'm assuming that you've made a GUI called difference_GUI using GUIDE in MATLAB.
When you do this, you'll get two files, difference_GUI.m and difference_GUI.fig. At that point, you should basically leave difference_GUI.fig alone, without opening or modifying it. Start the GUI by typing difference_GUI, which will run the .m file, which uses the information in the .fig file to lay out the GUI.
If you need to modify the layout of a GUI that you've created in GUIDE, you can open the project again in GUIDE and make minor modifications to it, such as repositioning a slider - but if you need to make major changes to it, I personally find it easier to copy the algorithmic portion out of the .m file, create an entirely new project, relaid out, from scratch, and then paste the algorithmic portion back in to the new .m file.

Matlab GUI's managebuttons

I have to maintain a large MATLAB GUI, containing quite a few callback functions, each of which gets called at many points. At some point, I decided to rename one of the callbacks; in order not to have to go through GUIDE to manually modify each of the UI that calls it, I used the excellent gencode program to "unwrap" the .fig file, s/old_name/new_name/g, and recreate the .fig.
This seems to work well, except for one thing: when clicking on a button in a button group, I got a message telling me that the function manageButtons is unknown. After a bit of googling, I find that manageButtons is a nested function in childAddedCbk, which, I assume, is called by GUIDE as the GUI is created. Now, trying to move just manageButtons outside to its own, in-the-path file doesn't work either: the hgroup passed to it is an invalid handle object.
So... does anyone has a workaround for that? Any of the following will be appreciated:
changing all the callbacks in a GUI in a semi-automatic way, or
making the manageButtons get a valid handle, or
having gencode not break all that.
Thanks,
Antony
You can export the FIG + M file to single .m file. You will lose the ability to edit this with guide, but you will be able to do a simple regular expression replace on the resulting .m file.
In order to do so - use on the menu of GUIDE -> File -> Export.

Resources