Finding mean and midpoint in each subintervals or bins
16 views (last 30 days)
Show older comments
Mel Hernandez
on 30 Mar 2018
Answered: Walter Roberson
on 30 Mar 2018
There are a few things I have to do with the excel data that I have. I have to put two columns, X and Y, into 36 equally spaced subintervals, Ij. In each of the subinterval, I have to find the average Y value of that subinterval. Then I have to find the midpoint of each subinterval.
This is what I have so far:
L = csvread('nameoffile.csv',1,0); %calling my file
data = [-1*L(:,4), L(:,5)]; %X = Column 4 of the excel and Y = Column 5
[N, edges, bins] = histcounts(data(:,1),36); %put the numbers into 36 bins
for n = 1:36
bin_means(:,n) = mean(data(bins==n,1))': %average Y in each bin/subinterval
bin_mdpt
end
I'm thinking of using edges, but I'm not sure how to set it up.
2 Comments
Accepted Answer
Walter Roberson
on 30 Mar 2018
To find the mean of each group,
splitapply(@mean, data(:,1), bins)
0 Comments
More Answers (0)
See Also
Categories
Find more on Spreadsheets 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!