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!