Matlab guide starts with axes already plotted - matlab

I created an application using GUIDE called (main). Inside the form (figure), i dragged and dropped many components, one of them is an axes component. When i run the application, it shows allways the same plot. GUIDE generated applications have an opening function, in my case, main_OpeningFcn. I already tried to clear (cla) it in the first line of main_OpeningFcn function, but it first blinks and old plot and then clears it. I am sure it is an old plot, i can recognize it. It seems like this old plot had been saved somewhere and everytime the application starts, it is shown. Is there any cache or something like that?

Maybe you accidently clicked on the save icon in your figure from the gui-window (not guide-window). Now when you open your gui, matlab will not create an empty plot, but will load whatever is saved in the fig-file, that exists beside the m-file for your guide-application.
To solve the issue, you need to delete the figure in your guide-editor, an place a new figure instead. And try to hide the menubar to avoid clicking the save icon again, if your gui is open.

Related

How to get drop downs on top o figure Matlab App Designer

I want a drop down box to be in my figure. The figure will be updated based on drop down selection; thus I want drop down to remain on top. I think I want the drop down to be a child of the figure/axis, but I do not know where to put this in the script. I am using App Designer in MATLAB 2017B. The Mathworks Documentation doesn't provide an example. It states under UI Figure Parent/Chlildren, "empty GraphicsPlaceholder array (default) | 1-D array of component objects"
Can someone provide an example code. I am sure this is simple, but spent hours searching. Thanks in Advance.
Tim
When I made the app, I added the drop downs, then the figure. The only way I could fix this was to delete the drop downs and then add them back. Unfortunately, the part of the script that Matlab creates the components is locked, so there was no way of moving the drop downs to after the figure. It took alot of work since I had a lot of drop downs, but its done.
Tim

Enable some component visibility in MATLAB GUI figure after a selection?

I have a simple question about matlab GUI?
how can i Enable some component visibility in MATLAB GUI figure? For an easy understanding i am using a fgure to explain my problem.
I wanted to do something like.
After Running my Gui. i wanted to show only a specific pushbutton rather all the components
as shown in Figure 1
Once i click on Lets ADD Button the figure 2 should appear
After selecting a number my Other Components should appear as shown in figure 3.
Sorry if my Words are misleading to you as i do not have a good command on technical words.
Thanks..........
You need to detect the event (i.e. press button) and create a function for that.
There you will need to enable the visibility of whatever you want like:
set(handles.pushbutton1,'visible','on')

Make an image a button in MATLAB

I am developing a GUI in MATLAB and am trying to allow a user to click on an image in order to enable a push button, and then this image will change like a toggle button, but I am struggling and am hoping for some advice, how can this be done?
I've seen that you can put icons on push buttons in MATLAB and that you can extract the position of the mouse on a click, but I can't figure out if these help my situation. I don't want to put the icon on the button because a) its not the look I am going for and b) I want to be able to change the image depending on the state of the button.
Thanks
The key to your problem is ButtonDownFcn. You need to set your images ButtonDownFcn to reference come function which both changes the image displayed, and does whatever else you need it to do. So, for example, say your create you image in you operating function like so:
...
yourImHandle = image(someImage);
set(yourImHandle, 'ButtonDownFcn', {#yourPushbuttonFcn, yourImHandle, otherVar});
...
Where yourPushbuttonFcn is defined elsewhere as:
function yourPushbuttonFcn(yourImageHandle, otherVar)
set(yourImageHandle, 'CData', someOtherImage);
otherVar=otherVar+1; %# Do other things.
end
This will change the image for you, and sets up the platform for you to do other, more complicated things inside the push button function. Let me know if you have any questions.
Good Luck.

MATLAB: GUIDE "Save Figure" toolbar button

I created a Gui in GUIDE and added the predefined "Save" toolbar button in guide->tools->toolbar. When i press the save button, the next time i open the GUI it will show the saved values and axes.
Now i would like to remove that feature again, but only removing the save button doesn't seem to work. The Gui still opens with the last saved values.
Is there a way to clear the saved data?
It appears that no further answers are forthcoming, and since I just ran across the same issue, this is what I did.
Open the object browser and determine which ones changed;
In my case it changed two text boxes as well as the axes.
Open the properties inspector for the changed objects and edit as required to return them
to their original states. I replaced the string property with the correct values.
It's too difficult to figure out how to make the axes object revert to it's old state. You can create a 2nd temporary axes and copy those states to the first axes; but I found this doesn't work. Instead, delete the old axes, create a new axes in it's place, and rename the tag to match the original. If there are any callbacks, make sure they're in the right place and delete the old one.
That's it. Good luck.

I have a few GUI's in MATLAB and I need to view them in different tabs

I have 3 GUI files created using GUIDE. I need to have a tab Panel where I can view all of them in different tabs.
There is no straightforward way to accomplish that. A figure cannot be displayed inside another figure. GUIDE creates figure. You can convert your GUIDE figure to programmatical GUI by using some conversion procedure. There is one official by Mathworks, or other ones on file exchange. Then, you should place the 3 figures children inside a panel each.
There is no tab object in MATLAB. You can generate your own by making your own graphical objects: the tab buttons, that users can click to run a function that puts the right "tab" in front using uistack to change the order of your graphical objects, always bringing the clicked tab to the front.
But you would do this all in one GUI, in one figure window; you just not to make sure that hold is on in the figure, and you have to give all your plots a handle so that you can manipulate them with uistack.