Reduce rows of data based on increment size
古いコメントを表示
I have a set of data with the depth, z (m) 0 until the maximum length. At the moment there is a total of 951 rows due to the small increment size of z. For analysis purposes, I only require the increment size to be 0.25 m.
So basically what I want to do is the following (pseudocode)
- Import the excel file into matlab.
- inc_size = 0.25
- Iterating through the rows, deltaZ_total = deltaZ(i)
- While deltaZ_total < (inc_size)
- deltaZ_total = deltaZ_total + deltaZ(i+1) % while the total of the increments is less than inc_size add them together
- Create a new row containing deltaZ_total and delete all the previous rows
- Skip a row % skip a row so the new increments are not being added to the previous
- Repeat the process until the end of the column
Could I please have some help translating this idea into matlab code.
Thanks very much,
Brian
4 件のコメント
Image Analyst
2020 年 9 月 19 日
- What is the delta z in meters between two rows?
- If you chose a larger increment size than whatever it currently is, would the number of rows be more or less than 951?
- How does the number of rows depend on the increment size? Is there some relation, correlation, dependency between them?
- How many rows would you expect for an increment size of 0.25?
Brian Robinson
2020 年 9 月 19 日
Image Analyst
2020 年 9 月 19 日
Not really, or very little. Are we talking about a 3-D dataset, like a CT or MRI volumetric image? Or just simply a 1-D situation where we have some number of elements in Z and the value of each element of Z is the depth into or above some material?
Please attach your data.
So, does Z go from say 20 to 10000 in 951 elements, but without a constant delta between each pair of elements in Z. Like it might be 0.1 between one pair of elements but 1.4 between a different pair of elements? And you want to resample that range 20-10000 with uniform spacing of 0.25. So the number of elements would be (max(z) - min(z)) / 0.25? Then you can just use linspace():
minValue = min(Z(:));
maxValue = max(Z(:));
numElements = (maxValue - minValue) / 0.25;
zUniform = linspace(minValue, maxValue, numElements);
Brian Robinson
2020 年 9 月 20 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Matrices and Arrays についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!