Finding mean and midpoint in each subintervals or bins

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 Commenti

You can find the midpoints easily:
bin_mdpt=(edges(2:end)+edges(1:(end-1))/2;

Accedi per commentare.

 Risposta accettata

Più risposte (0)

Categorie

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by