Reducing number of elements.

22 ビュー (過去 30 日間)
大輝 渡辺
大輝 渡辺 2021 年 9 月 27 日
コメント済み: 大輝 渡辺 2021 年 9 月 27 日
I have a raw matrix (for example, size is 100 x 1).
I would like to calculate an average value in each 10 elements, then substitute this average value to new matrix.
Here, I dont want to use 'for loop' because actual raw data is very huge..
Do you have any idea to calculate the average value without for loop..
Thank you very mcuh,

回答 (1 件)

Stephen23
Stephen23 2021 年 9 月 27 日
V = rand(100,1)
V = 100×1
0.8711 0.0119 0.7122 0.0248 0.6226 0.2492 0.9730 0.5473 0.0675 0.2847
Z = mean(reshape(V,10,10),1).'
Z = 10×1
0.4364 0.5550 0.3497 0.7366 0.3949 0.4595 0.4442 0.5738 0.3501 0.3926
  1 件のコメント
大輝 渡辺
大輝 渡辺 2021 年 9 月 27 日
Oh, Nice! Thank you very much!!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by