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?
조회 수: 11 (최근 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.
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.
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에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!