How to plot multiple plots repeatedly from a loop?
3 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
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.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!