Given the complexity of my data set, I gave up trying to figure this out. Instead I resampled the data so that the start and end y values are the same over a certain length determined by the depth values. Basically, I doubled my data length and y samples. It works and can handle the gaps in the data just fine.
Create stair plot with uneven spaced data?
8 次查看(过去 30 天)
显示 更早的评论
I guess I am over thinking this, but I can't seem to find a solution to my problem.
I have a several columns of variables that represent the mid points of two depths. The depths are not evenly spaced. Some represent 3cm, some 4, others 5 or even 5cm. I would like to create a stair step plot that will handle unevenly spaced depths. See image. Column 1 is my start depth, Column 2 my end depth. Column 3 is the variable to be plotted.
![Capture9.JPG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/200816/Capture9.jpeg)
I looked at the stair function and this will create the plot I would like, but I haven't been able to figure out how to use it with user defined spacing that is also uneven.
using the stairs code,
figure; stairs(DepthCopy(1:100,1),DepthCopy(1:100,3))
I come up with this graph, however, the long line between 6 and 6.5 should be a gap as their is no data for this section. It handles the smaller gaps fine when there is a depth but no data, but not when there no depth and no data.
![Capture7.JPG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/200817/Capture7.jpeg)
Is my only option to resample the data down to the smallest increment and fill in the fake gaps with NaN?
Any suggestions?
0 个评论
采纳的回答
Cg Gc
2019-1-16
2 个评论
Walter Roberson
2019-1-16
It is possible without resampling. Unfortunately I was responding in the middle of my night, and it was escaping me as how best to do it in vectorized fashion, so I headed to bed...
更多回答(1 个)
Walter Roberson
2019-1-16
When you use stairs() there is no requirement that the x values be evenly spaced.
Supposing your data is in DD:
stairs([DD(1:8,1),DD(8,2)],[DD(1:8,3),DD(8,3)])
hold on
stairs([DD(9:end,1),DD(end,2)],[DD(9:end,3),DD(end,3)])
hold off
You cannot do it as one continuous plot because the right edge of row 8 has a gap of 5 mm before the start of row 9.
3 个评论
Walter Roberson
2019-1-16
where I used [DD(something ),DD(something )] use semicolon between the parts.
I pointed out the 5 mm gap and created a second plot to handle it since you were emphasising the importance of the irregularities . Is that gap in fact significant or can we assume that the sections are contiguous or is there some larger gap that is significant while 5mm is not?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!