Producing multiple figures in a 'for' loop

2 ビュー (過去 30 日間)
Jay
Jay 2014 年 3 月 6 日
コメント済み: Mahesh Yumnam 2020 年 11 月 17 日
Hello,
I would like to produce mutliple figures (i.e figure 1,2,3..n on separate windows). I am using different values of 'n' in my code and this means the plotting graph changes. How do I go about getting separate windows for each iteration? Currently the final iteration is produced only. Thanks! Note I am calling function 'myfunc' that I have made and produces a vector that I plot.
Code:
clear
for n=1:20
x=linspace(-5,5,n+1) %linear spacing of n+1 x values on [-5,5]
y=cos(x) %function points given exactly
z=linspace(-5,5,200) %equally spaced vector of 200 points on [-5,5]
p=myfunc(x,y,z) %calling 'myfunc' produces points to be plotted against z
fig=plot(x,y,'o',z,cos(z),'-b',z,p,'--r')
set(fig(1),'MarkerFaceColor','g')
end
Thanks for any help!

採用された回答

Walter Roberson
Walter Roberson 2014 年 3 月 6 日
Right after the "for", use
thisfig = figure();
I also recommend parenting all the graphics updates; see http://www.mathworks.co.uk/matlabcentral/answers/22208-show-figure
  2 件のコメント
Jay
Jay 2014 年 3 月 6 日
Thank you, that works fully. Much appreciated!
Mahesh Yumnam
Mahesh Yumnam 2020 年 11 月 17 日
Thank you. This solved my problem

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by