How to average data within bins when values are not integers?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Matt J
le 12 Mar 2021
numBins=10;
bins=discretize(new_u10wcav,numBins);
meany=splitapply(@mean,wc_average(:),findgroups(bins(:)));
0 commentaires
Voir également
Catégories
En savoir plus sur NaNs dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!