Info

This question is closed. Reopen it to edit or answer.

how do I solve this problem? please is for my thesis and deadline is getting closer

1 view (last 30 days)
I am programing code in which after I press the push button a series of operations are gonna be made and create lots a variables and vectors into the pushbutton1 function, I need to plot 5 diferents graphs, the think is that I created a pop-up-menu called popupmenu1 in which there are 5 options making reference to the 5 diferents plots I want to appear one at a time in the same axes I created called axes1, so for example I pressed the push button and the first graphic is gonna apear by default, but if the user want to see the 2th or 3th or 4th or 5th graph he just have to change te option in te pop up menu and automaticly without having to press again the button change the graph to the other one selected by the user, I have already writen the code in the popupmenu1 callback, but I have 2 issues,
1.as the popupmenu1 callback is in a diferent function of the pushbutton1 callback the variables I put in there appear not being defined yet, beacuase they exist in the push button function but no in the popupmenu1 function so I am looking for a way to define the globaly
2. I was able to do the code works in some way good but need to press the push button to refresh I guess, and the graphic appear one over the other one, so obviously beacuse of scales and stuff appears horrible, and I need to hide or errase the old one and only to show the new one with his own limits and stuf

Answers (1)

Walter Roberson
Walter Roberson on 4 Oct 2015
You can delete() the existing graphics objects or you can turn hold off on the axes before doing the next plot. You could also cla() the axes but that would affect tick marks and so on (which would probably be okay for your purpose.)
The best approach would be to update the properties of the graphics objects rather than creatin new graphics objects, but that requires more knowledge of how the graphics works.

Community Treasure Hunt

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

Start Hunting!