Loop how to sum part of matrix
조회 수: 1 (최근 30일)
이전 댓글 표시
if I have a 9x3 matrix A=[123;123;456;212;121;111;312;141;010] AND i want to get matrix B dimension 3x3 (see photo) so that cell 1,1 would have a sum of 1+2+3 (so in first coulmn of A matrix taking 1,1 cell and 4,1 cell and 7,1 cell) and in the entry of matrix B 2,1 it would be 1+1+1 (taking from matrix A cell 2,1 and 5,1 and 8,1) and in matrix B the entry 3,1 would take from A 4+1+0 so 3,1 cell and 6,1 cell and 9,1 cell and the same logic for column 2 of B and column 3 of B to get at the end B=[647;385;577]
This was just an example in reality I need the same logic for much larger matrix dimension (from 1435x35 getting it into 35x35) so I would be really grateful for loop command or some other help to get the logic of this....
댓글 수: 0
답변 (1개)
Cris LaPierre
2021년 1월 19일
댓글 수: 2
Cris LaPierre
2021년 1월 19일
The documentation I linked to contains examples. Take a stab at it yourself first. If you get stuck, share your code and a specific question about what you are not understanding.
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!