필터 지우기
필터 지우기

If I have a 2000 x 130 matrix, how do I convert it to a 500 x 130 matrix by adding all four rows together by using Matlab loop

조회 수: 2 (최근 30일)
.

채택된 답변

KSSV
KSSV 2022년 1월 12일
편집: KSSV 2022년 1월 12일
A = rand(2000,130) ;
[r,c] = size(A);
nlay = r/4;
B = permute(reshape(A',[c,r/nlay,nlay]),[2,1,3]);
iwant = reshape(sum(B),[],c) ;
  댓글 수: 2
Haytham Ali
Haytham Ali 2022년 1월 12일
@KSSV thank you
Can you tell me how to sum all 4 elements or rows
Since I want to calculate the average for each of the four elements by calculating their sum divided by their number
KSSV
KSSV 2022년 1월 12일
Sum is already included in the code.... To get the average just use mean. Read about this function.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by