Refresh plot using switch case with dropdown menu in App designer

13 views (last 30 days)
rajahn
rajahn on 10 Jan 2022
Commented: VBBV on 14 Jan 2022
Hi everyone,
I have designed an app, which has a drop down menu to select what will be ploted and it works fine. I want to improve the app, so that when I change the value of X or Y lim in numeric fields it will be automatically refreshed. For now, after changing the value in the numeric field I have to select again the same plot in my dropdown menu, to see the plot with the new limits for both axes.
For the limits on the X and Y Axes I am using following commands:
xlim(app.UIAxes, [app.Xmin app.Xmax])
ylim(app.UIAxes, [app.Ymin app.Ymax])
for this app I should avoid using the timer function. Is there another way to refresh the Axes and see the plot with the new limit?
Thank you!

Answers (1)

VBBV
VBBV on 10 Jan 2022
Edited: VBBV on 10 Jan 2022
plot(x,y)
ax = gca % get the axes handle of current plot
delete(ax);% delete the axes handle
Hope this works
  2 Comments
VBBV
VBBV on 14 Jan 2022
ax = axes
plot(ax,x,y)
axes('Position',ax.Position,'XLim', [Xmin Xmax],'YLim',[Ymin Ymax]);% assign the new axes range
Check with this

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!