Plot for two range of x

조회 수: 6 (최근 30일)
Atom
Atom 2013년 2월 15일
I have two ranges of x = [0:0.01:1] and x = [2:0.01:3] and I want to plot x vs. Y in one plot for the two rages of x values without using hold on command. Is it possible in matlab?
Below I have used hold on command (which I don't want to use) to plot
x = [0:0.01:1]
Y = x./5;
plot(x, Y, 'Color',[0.85 0.16 0], 'linewidth', 2);
hold on
x = [2:0.01:3]
Y = x./5;
plot(x, Y, 'Color',[0.85 0.16 0], 'linewidth', 2);

채택된 답변

Honglei Chen
Honglei Chen 2013년 2월 15일
Something like this?
x = [0:0.01:1 nan 2:0.01:3]
y = x./5
plot(x,y)
  댓글 수: 1
Atom
Atom 2013년 2월 15일
Yes I want this exactly. Thank you very much. Where to see the details about nan ?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Jos (10584)
Jos (10584) 2013년 2월 15일
Or still separate them in different graphic objects:
x1 = [0:0.01:1] ;
y1 = x1./5;
x2 = [2:0.01:3] ;
y2 = x2./5;
plot(x1, y1, '-', x2,y2,'-', 'Color',[0.85 0.16 0], 'linewidth', 2) ;

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by