필터 지우기
필터 지우기

Averaging Every Element of some matrices

조회 수: 1 (최근 30일)
Joydeb Saha
Joydeb Saha 2020년 10월 6일
편집: Stephen23 2020년 10월 7일
I have 40 matrices of 12x1. How can I take the the each element of every matrix and get a averaged matrix which will be 12x1

채택된 답변

Stephen23
Stephen23 2020년 10월 6일
The simple answer is to concatenate all of your matrices into one array, and then use mean. Of course all of your matrices should be in one cell array, because that makes them much easier to work with:
C{1} = [..];
C{2} = [..];
..
C{40} = [..];
A = cat(3,C{:});
M = mean(A,3)
  댓글 수: 3
Joydeb Saha
Joydeb Saha 2020년 10월 7일
C{1} = [total1979_125_30];
C{2} = [total1980_125_30];
C{3} = [total1981_125_30];
C{4} = [total1982_125_30];
C{5} = [total1983_125_30];
...upto C{40} = [total2019_125_30];
just help me making the loop
Stephen23
Stephen23 2020년 10월 7일
편집: Stephen23 2020년 10월 7일

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

KSSV
KSSV 2020년 10월 6일
Read about mean. You can specify your required dimension to get the mean along.
A = rand(12,1,40) ;
M = mean(A,3) ;
  댓글 수: 1
Joydeb Saha
Joydeb Saha 2020년 10월 7일
I understand and thank you for the support. Can you just help me out by making a loop for the 40 matrices? say..
C{1} = [..];
C{2} = [..];
..
C{40} = [..];
My matrices are in the name as 'total1979_125_30' , 'total1980_125_30', ... upto 'total2019_125_30' . Each are having 12x1 format.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by