How to average data within bins when values are not integers?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I'm analyzing whitecaps, named 'wc_average', against wind speed ('new_u10wcav'). I want to bin the windspeeds and average the whitecaps within those bins. I've tried to use accumuarray but I keep getting errors since my data aren't positive integers. The current code I've been trying comes up with the error
Error using splitapply (line 101)
The data variables must have the same number of columns as the vector of group numbers. The group number vector has 11 column(s), and data variable 1 has 1 column(s).
How do I fix it? My current code:
numBins=10;
[N,edges]=histcounts(new_u10wcav,numBins);
meany=splitapply(@mean,wc_average,findgroups(edges));
The data should be founds in testfiles.mat that I attached.
0 comentarios
Respuestas (1)
Matt J
el 12 de Mzo. de 2021
numBins=10;
bins=discretize(new_u10wcav,numBins);
meany=splitapply(@mean,wc_average(:),findgroups(bins(:)));
0 comentarios
Ver también
Categorías
Más información sobre NaNs en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!