フィルターのクリア

Computing the mean over 3 numbers in a matrix

3 ビュー (過去 30 日間)
mohamad shirgholami
mohamad shirgholami 2021 年 6 月 6 日
コメント済み: Image Analyst 2021 年 6 月 6 日
I have a matrix with dimensions of 5000*51. I want to find the average over each 3 numbers and finally I have a matrix of 5000 * 17.
  1 件のコメント
Image Analyst
Image Analyst 2021 年 6 月 6 日
Do you want a moving mean where the window of 3 moves over one row, or one column, each time, or do you want the window to move in jumps of 3? Do you want 3 in the same row to be averaged? Or do you want the 3 to be in the same column? Which way do you want the mean to go????

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

採用された回答

KSSV
KSSV 2021 年 6 月 6 日
Let A be your matrix.
[m,n] = size(A) ;
B = reshape(A,m,3,[]) ;
C = mean(B,2) ;
iwant = reshape(C,m,[]) ;

その他の回答 (1 件)

Chunru
Chunru 2021 年 6 月 6 日
A = rand(5000, 51); % your data
A1 = reshape(A, [5000 3 17]); % reshape the 51 element by 3x17 array
meanA = mean(A, 2); % Mean along 2nd dimension
  2 件のコメント
mohamad shirgholami
mohamad shirgholami 2021 年 6 月 6 日
meanA = mean(A1, 2);
mohamad shirgholami
mohamad shirgholami 2021 年 6 月 6 日
thanks for your answer.

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

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by