- 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?
Reduce rows of data based on increment size
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Brian Robinson
le 19 Sep 2020
Commenté : Ameer Hamza
le 20 Sep 2020
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 commentaires
Image Analyst
le 19 Sep 2020
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);
Réponse acceptée
Ameer Hamza
le 19 Sep 2020
Instead of deleting the rows, I suggest using interp1() to get the required output
z = .. % 951x1 vector
x = .. % 951x1 vector of data points
z_new = 0:0.25:max(z); % new z vector have increments of 0.25
x_new = interp1(z, x, z_new); % x_new are data points corresponding to z_new.
6 commentaires
Ameer Hamza
le 20 Sep 2020
I think you want something like this
load pile_data.mat
purdueUS52MODIFIEDS2(1,:) = []; % first row is NaN, removing it
data = table2array(purdueUS52MODIFIEDS2);
count = 1;
while size(data, 1) ~= count
if data(count+1, 20) < data(count, 20)+0.25
data(count+1, :) = [];
else
count = count + 1;
end
end
data(2:end, 21) = diff(data(:, 20));
table_new = array2table(data, 'VariableNames', purdueUS52MODIFIEDS2.Properties.VariableNames);
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!