フィルターのクリア

Plot on many figures using cellfun

4 ビュー (過去 30 日間)
Ahmad Gad
Ahmad Gad 2021 年 2 月 9 日
コメント済み: Walter Roberson 2021 年 2 月 9 日
Hello all,
I have a cell array t and T defined for simplicity as the following:
t = {rand(1,10),rand(1,10)};
T = {rand(1,10),rand(1,10)};
I am trying to plot t against T on two different figures, not a single figure. When I used this,
cellfun(@(x,y) plot(x,y), t,T);
They override each other on a single figure. Is there any way to plot them individually on two figures?
Thanks in advance for the help,
Ahmad Gad
  1 件のコメント
Ahmad Gad
Ahmad Gad 2021 年 2 月 9 日
@Walter Roberson, can you help here?

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

採用された回答

Jan
Jan 2021 年 2 月 9 日
編集済み: Jan 2021 年 2 月 9 日
CELLFUN is not really useful here, because it increases the complexity. Do this with a loop instead:
t = {rand(1,10),rand(1,10)};
T = {rand(1,10),rand(1,10)};
for k = 1:numel(t)
FigH = figure;
AxesH = axes(FigH);
plot(AxesH, t{k}, T{k})
end
If you have any good reasons to hide the details in cellfun():
cellfun(@(x, y) plot(axes(figure), x, y), t, T)
The loop is nicer.
  3 件のコメント
Jan
Jan 2021 年 2 月 9 日
I've edited the cellfun version.
Walter Roberson
Walter Roberson 2021 年 2 月 9 日
When doing graphics operations in a cellfun() or arrayfun() or structfun(), make sure to use "hold on" unless you are generating a new axes or figure each time (which Jan's code does do.)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by