Adding matrix elements (entering matrices into other matrix)

조회 수: 16 (최근 30일)
Dean
Dean 2012년 9월 28일
my code:
A= zeros(3,3)
B = ones(2,2)
C = ones(2,2)
A(1:2,1:2) = B
A(2:3,2:3) = C
right now it gives: A=
1 1 0
1 1 1
0 1 1
I want the 2,2 position to add instead of simply replace. I want the final output to be:
A=
1 1 0
1 2 1
0 1 1
thanks

채택된 답변

Teja Muppirala
Teja Muppirala 2012년 9월 28일
How about:
A(2:3,2:3) = A(2:3,2:3) + C

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by