How to establish the handle value of a personalized plot function?

3 visualizaciones (últimos 30 días)
I need to develop a program that will:
(a) plot one set of data into a figure at a time,
(b) when the next set of data is plotted, the previous plot needs to be removed.
I definied my own functioned as below:
function plot1(a, b, c, d)
plot ...
plot ...
plot ...
.... % a total of about 50 plots
end
It works very well by calling the program as below:
plot1(a, b, c, d)
Here is the problem. Because I need to remove the previous plot, I'm trying to give the plot a handle, so that I can use delete(app.A) to remove the previous plot.
app.A = plot1(a, b, c, d)
Now Matlab is complaining:
Too many output arguments.
How do I rewrite my plot program so that it can be assigned with a handle like the normal Matlab function "plot".
Many thanks.

Respuesta aceptada

Walter Roberson
Walter Roberson el 13 de Mzo. de 2021
function plots = plot1(a, b, c, d)
plots(1) = plot ...
plots(2) = plot ...
plots(3) = plot ...
.... % a total of about 50 plots
end
However, have you considered just using
cla(app.AppropriateAxesHandle);
or
delete(findobj(app.AppropriateAxesHandle, 'type', 'line'));
  1 comentario
Leon
Leon el 14 de Mzo. de 2021
Many thanks for the amazing resolution!
delete(findobj(app.AppropriateAxesHandle, 'type', 'line'));
The above recommended solution solves my issue beautiful.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by