필터 지우기
필터 지우기

Plotting discontinuos X Data

조회 수: 1 (최근 30일)
Moiz
Moiz 2016년 1월 2일
답변: Mike Garrity 2016년 1월 4일
I have a data set that looks like this :
datax = [6 7 8 9 14 48 49 50 55 87 88 89];
datay = [1 1 1 1 2 3 3 3 4 5 5 5];
I want to make a single figure which will have essentially 5 lines corresponding to every jump in the x data. The first line will be ones reperesenting X index 1:4 i.e, 6,7,8,9 The second line will be a single point at 2 representing X index 5 i.e, 14 The third line will be threes representing X index 6:8 i.,e 48,49,50 and so on. Also the code should be extendable to any datax with discontinuities like shown above and produce a new line at every discontinuity.

채택된 답변

Mike Garrity
Mike Garrity 2016년 1월 4일
You can use nan to represent discontinuities:
datax = [6 7 8 9 nan 14 nan 48 49 50 55 nan 87 88 89];
datay = [1 1 1 1 nan 2 nan 3 3 3 4 nan 5 5 5];
plot(datax,datay,'-o')

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by