Plotting discontinuos X Data

1 次查看(过去 30 天)
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 中查找有关 Line Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by