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

1 回表示 (過去 30 日間)
Leon
Leon 2021 年 3 月 13 日
コメント済み: Leon 2021 年 3 月 14 日
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.

採用された回答

Walter Roberson
Walter Roberson 2021 年 3 月 13 日
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 件のコメント
Leon
Leon 2021 年 3 月 14 日
Many thanks for the amazing resolution!
delete(findobj(app.AppropriateAxesHandle, 'type', 'line'));
The above recommended solution solves my issue beautiful.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by