I want to add a column that counts the passes for this test. When the values in the first column are between 0-300 seconds, I want to consider that pass 1, etc.
1 view (last 30 days)
Show older comments
I want to add a column that counts the passes for this test. When the values in the first column are between 0-300 seconds, I want to consider that pass 1, etc.
I figured out how to add a new column:
%Add new columnm to mark passes
passestest= zeros(size(CETR,1),1);
CETR=[CETR,passestest];
I would then like to find the averages for each of the passes (averages of all rows in pass 1).
2 Comments
Answers (2)
Walter Roberson
on 25 Jan 2018
Possibly you want to use histcounts(), passing in edges like [0 300 450 ....] to count 0 <= x < 300, 300 <= x < 450, and so on
2 Comments
Steven Lord
on 25 Jan 2018
The histcounts function returns bin counts as its first output and bin membership numbers in its third output. The discretize function returns bin membership numbers in its first output. In this case I'm going to get histcounts tell me what edges it used and reuse those edges in discretize. If you know the bin edges you want to use, you can specify them in either histcounts or discretize.
x = randperm(100, 25);
[bincounts1, edges1, binlocations1] = histcounts(x)
binlocations2 = discretize(x, edges1)
isequal(binlocations1, binlocations2) % true
From your description you're more interested in binlocations1 (or binlocations2, since they're the same) than bincounts1.
See Also
Categories
Find more on Oceanography and Hydrology in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!