How to plot multiple plots within a for loop using hold on?
古いコメントを表示
Hello, using the following code, when I plot the graphs matlab gets confused and starts plotting some of the data within other plots.
For i = 1:10
plot(x1, y1)
semilogy(x2,y2)
xlabel('Name')
ylabel('Name')
hold on;
figure
subplot(3,1,1)
plot(x3,y3)
xlabel
ylabel
axis tight;
subplot(3,1,2)
semilogy(x4,y4)
xlabel
ylabel
axis tight;
hold on;
subplot(3,1,3)
semilogy(x5,y5)
xlabel
ylabel
axis tight;
hold on;
end
The result I want to achieve is 2 different plots. One plot using the variables x2 and y2, and a second plot which contains 3 subplots. When I run this code it plots some of the variables x2 and y2 on the subplots. I am unsure as to why this occurs, I believe it is something to do with the hold on part although I'm not sure what part of is wrong.
回答 (1 件)
Star Strider
2016 年 11 月 27 日
0 投票
If I understand your problem correctly, just delete the hold calls in the subplots. It seems to me that you do not need them.
2 件のコメント
Tharuka Devendra
2016 年 11 月 27 日
編集済み: Star Strider
2016 年 11 月 27 日
Star Strider
2016 年 11 月 27 日
I have no idea how to interpret those plots, or determine what is ‘wrong’ with them. I suggest you keep experimenting until you get the result you want.
Since I cannot help with this, I will delete my Answer in a few minutes.
カテゴリ
ヘルプ センター および File Exchange で 2-D and 3-D Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!