Multiple plots in Matlab app designer, with changing values.

I want to draw a vertical line over a function, but when I change the vertical line's position using a slider it draws several other lines instead of moving it.
How can I draw multiple plots in app designer that can be changed without it keeping the previous version of the plot ?

 Respuesta aceptada

Adam Danz
Adam Danz el 4 de Mayo de 2020
Editada: Adam Danz el 4 de Mayo de 2020
In the slider callback function, instead of using the same command to plot a new vertical line, update the x value of the vertical line.
persistent verticalLineHandle % or declare the handle as an app property
if isempty(verticalLineHandle)
verticalLineHandle = xline(app.uiaxes, x); % x = slider value, I suppose
else
verticalLineHandle.Value = x; % x = slider value, I suppose
end

Más respuestas (0)

Categorías

Más información sobre Develop Apps Using App Designer en Centro de ayuda y File Exchange.

Productos

Versión

R2020a

Preguntada:

el 4 de Mayo de 2020

Editada:

el 4 de Mayo de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by