필터 지우기
필터 지우기

Filling the matrix entries

조회 수: 1 (최근 30일)
Teshome Kumsa
Teshome Kumsa 2022년 5월 25일
답변: Image Analyst 2022년 5월 25일
I have a matrix to deal with.
A=[1 2 3 4 5 6 7;4 6 7 4 5 8 7; 6 7 8 9 3 5 6];
for i=1:3
A(i,i)=0;
end
In the above simple code I could change A(i,i) by 0. Now I want to start from the last entry(A(3,7)) and change to 0 in the similar way. In simple way A(3,7), A(2,6,) and A(1,5) should be changed by zero. I need it in the loop I started.

채택된 답변

Image Analyst
Image Analyst 2022년 5월 25일
Perhaps this:
A=[1 2 3 4 5 6 7;4 6 7 4 5 8 7; 6 7 8 9 3 5 6]
A = 3×7
1 2 3 4 5 6 7 4 6 7 4 5 8 7 6 7 8 9 3 5 6
for k = 1 : 3
A(k, k+4)=0;
end
A % Display result
A = 3×7
1 2 3 4 0 6 7 4 6 7 4 5 0 7 6 7 8 9 3 5 0

추가 답변 (0개)

카테고리

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

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by