How to plot multiple plots repeatedly from a loop?

3 ビュー (過去 30 日間)
Richa
Richa 2017 年 4 月 14 日
コメント済み: Richa 2017 年 4 月 14 日
I have a code which has a 'for' loop running three times. For each iteration, the script computes the value of three functions, let F1, F2 and F3. I have:
figure()
for k=1:1:3
some variable computations;
F1(k)=Value1;
F2(k)=Value2;
F3(k)=Value3;
plot(F1,F2);
hold on
end
This script plots F1 against F2 on the same plot for 3 levels of k. Thats what I need. But now I wish to plot F2 with F3 also from the same script. This needs to be a separate plot, but should also consist of all three plots for 3 levels of k. If I add a new 'figure' before writing plot (F2, F3), it will create 3 plots for 3 levels of k, while I need all of them on one plot. Please guide.

採用された回答

Rik
Rik 2017 年 4 月 14 日
There are two options: use a specific figure number for each plot, or use a handle for the two figures. I would advise the first method. Just use figure(1) and figure(2). The second option requires an additional step to create an axis.
f1=figure;
h1=gca;
f2=figure;
h2=gca;
Now you can use the two handles in the plot command. Don't forget that you have to set hold on for each axis separately.
  1 件のコメント
Richa
Richa 2017 年 4 月 14 日
Thank you very much for your help Rik.

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

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by