Matlab App Desinger: How to update a figure with button
Show older comments
Hello,
I want to create multiple plots in an app and later update the plots when new data is added.
In one step the user can add data (in this case a trajectory) and plot a preview. Later on the user can add another data (a single coordinate inside the trajectory) and I want this new point to be plotted inside the wirst figure window. Right now I'm having the issue that App Desinger always opens a new window.
Here's a simplified version of my code so far:
app.counter = 0;
function FirstButtonPushed(app, event)
% check if user selected a file yet
position = importfile1(filename); % imports table with Lat and Lon
% plot the preview
fig_trajectory = uifigure('Name', 'Trajectory');
hold on;
plot(position.Longitude, position.Latitude);
% check if user has skipped this step and already added the new additional data
if app.counter >= 1
plot(app.vpos(:,2), app.vpos(:,1), '*')
end
end
function SecondButtonPushed(app, event)
app.pos = [48.0000 11.0000; 48.0001 11.000];
app.counter = app.counter +1;
% call previous plot
% add data
plot(app.pos(:,2), app.pos(:,1), '*')
How can I tell Matlab to update the figure?
Thanks in Regards!
Accepted Answer
More Answers (0)
Categories
Find more on Develop Apps Programmatically in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!