Delete points on UIAxis in App Designer

Hello,
I have a plot in App Designer (2020a) that plots a flight path in altitude vs. time and overlays the time-of-detection points onto the flight path. With this plot there is a drop down menu that allows the user to select a specific detection, and all the data correlated with that detection will pop up in another area.
hold(app.Axis,'on')
plot(app.Axis,time,altitude) %plots flight path
scatter(app.Axis,detTime,detAlt,'*') %plots detections along flight path in time and altitude
What I would like to do is have the selected detection point "highlighted" on the plot when the ValueChanged callback is used in the drop down menu, so that every time a new detection point is selected, the new point is highlighted and the previous point is no longer highlighted. I have "highlighted" the point by plotting the coordinates of the selected point on the axis with a bigger line width.
I have tried two method to delete the point. Firstly, I cleared the plot entirely, which is impractical for the application of this app becaues all of the original data would need to be replotted each time and would cause user confusion. Secondly, I have tried setting these specific plotted points to handles and the deleting the handle at the beginning of the callback. With this method, the variable appears to not exist; and when I just put the "delete(pointHandle)" line of code into the command window during debugging, I get the error "Unrecognized function or variable".
%% beginning of callback
if exist(pointHandle)
delete(pointHandle) %delete old selected point
end
%% somewhere in the middle of the callback
hold(app.Axis,'on')
plotHandle = plot(app.Axis,selTime,selAlt,'Marker','*','LineWidth',3) %plot selected point on plot, but make it big
Ideally, this section of code would work by:
  1. Change the value of the drop down menu in the callback.
  2. Check if the pointHandle exists.
  3. The old pointHandle value is deleted, therefore removing the point from the plot.
  4. Assign a new pointHandle value, therefore plotting a new point on the plot.
  5. Repeat at every value change.
Currently, the code just ignores the "delete" command because the variable does not exist. I suspect this is because the workspace is cleared once a callback is completed. This means that the old point remains "highlighted" even after a new point is selected and "highlighted".
Is there a way to delete the old point in the callback? I do not want to use brushing (the user should not have to manipulate the plot in any way), and the currently selected point needs to remain highlighted while other callbacks are being used.
Thanks!

 Risposta accettata

Cris LaPierre
Cris LaPierre il 14 Lug 2021
Try adding your pointHandle as a property of the app. That way, it will persist in the app structure. You would then use it using dot notation: app.plotHandle.
See the Share Data Within App Designer page for details.

Più risposte (0)

Categorie

Scopri di più su Develop Apps Using App Designer in Centro assistenza e File Exchange

Prodotti

Release

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by