Addition for loop in matrices

조회 수: 2 (최근 30일)
Surendra Maharjan
Surendra Maharjan 2021년 3월 26일
댓글: Rik 2021년 3월 26일
Hello Matlab Community,
I would like to add A and B matrices using for loop such that I can add B into A, element-wise 2x2, and moving column-wise till 5th element and move to second row, and adding B and moving column till 5th element again and move to third row and fourth row consequently.
A = zeros(5,5);
B = [1, 2; 3, 4];
Thank you very much.
Suren
  댓글 수: 2
Stephen23
Stephen23 2021년 3월 26일
@Surendra Maharjan: please show the expected output for your example data.
Rik
Rik 2021년 3월 26일
25 is not a multiple of 4. Should the replication of B just stop there?

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by