How would I divide a 206x1 double it into 5 equal sections and average the values

1 回表示 (過去 30 日間)
Emily Heil
Emily Heil 2020 年 3 月 30 日
回答済み: David Hill 2020 年 3 月 30 日
I have want to average the data from a 206x1 double in 5 sections. In other words I want to average from 1-41.2, from 41.2-82.4, etc. without matlab rounding the element number to the nearest integer. Is this possible?

回答 (1 件)

David Hill
David Hill 2020 年 3 月 30 日
I am not exactly sure what you mean. If you have matrix (M -206x1) and you want to find the mean of different groupings, then:
[~,~,a]=histcounts(M,[1,41.2,82.4,123.6,164.8,206]);%or whatever groupings you want
for k=1:5
m(k)=mean(M(a==k));%calculates the mean of each grouping and stores them in array (m)
end

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by