Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Cannot make several plots in one graph with the command "hold on"

조회 수: 1 (최근 30일)
raphael reis nunes
raphael reis nunes 2017년 2월 22일
마감: MATLAB Answer Bot 2021년 8월 20일
Hello,
as a total beginner in MatLab, I tried to create a graph with several plots on it using the command hold on.
Like :
x1 = linspace(1,10,10); f1 = x1.^2/2.*sin(x1);
x2 = linspace(1,20,20); f2 = x2.^2/2.*sin(x2);
x3 = linspace(1,100,100); f3 = x3.^2/2.*sin(x3);
plot(x1, f1, 'b');
hold on;
plot(x2, f2, 'g');
plot(x3, f3, 'r');
But the only plot that stays is the last one. Need help please !
Thanks'

답변 (1개)

dbmn
dbmn 2017년 2월 22일
funny, all the 3 lines stay exactly on each other, that way you dont see the other two lines. So everything is working as it should.
You can see the plots by specifying a marker
plot(x1, f1, 'bo');
hold on;
plot(x2, f2, 'g*');
plot(x3, f3, 'r');

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by