I am working on a UI that has a mesh plot and a scatter point that updates depending on the value, how do I allow the scatter point to update?
2 views (last 30 days)
Show older comments
I am making a UI to plot a mesh grid. I use 'hold on' to allow me to plot a scatter point on top of the grid. The user uses sliders or the editable text box to insert values that should update a point that corresponds to the red point. I have attached an image of what it looks like, however I cannot figure out how to update the red point. I have attached the beginning code to plot it as an example of how I am doing it. What I think I want to do is to update the entire plot of the mesh and scatter point again but I cannot think of how to update the mesh with the scatter again. I am not using GUIDE or the app designer. Thank you for any help.
% create the figure in windowed position
F.fh = figure('Name','Airfoil Plot','NumberTitle','off');
F.fh.WindowState = 'maximized';
% function for the plotting
F.fcn = @(Angle,Speed) griddata(xq,yq,zq,F.Angle,F.Speed);
% create plot of mesh that they choose AoA and V from
F.ax = axes('position',[.1 .3 .7 .7]);
F.ms = mesh(xq,yq,zq);
hold on;
F.red = scatter3(F.Angle,F.Speed,F.z,50,[1 0 0],'filled');
hold off;
view([20 35]);
rotate3d on;
2 Comments
Answers (1)
Walter Roberson
on 25 Jun 2018
If "update a point that corresponds to the red point" is intended to refer to F.red, then instead of redrawing anything, to update the location, set the XData, YData, Zdata properties of F.red to correspond to the new location. (And call drawnow() afterwards to make the change visible.)
0 Comments
See Also
Categories
Find more on Scatter Plots 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!