Error in my code

조회 수: 2 (최근 30일)
Igina
Igina 2013년 6월 19일
Hi, everybody, MATLAB tells me that this code in the 3rd "while" has a problem (MAT is a matrix):
ir=1;
while(ir<=length(MAT(1,:)))
ic=1;
while(ic<=length(MAT(:,1)))
while(MAT(ir,ic)==0)
MAT(ir,ic)=6;
end
ic=ic+1;
end
ir=ir+1;
end
Just to be more precise: with this code I want to replace the zero entries of the matrix MAT with the number 6. Thank you!

채택된 답변

Jonathan Sullivan
Jonathan Sullivan 2013년 6월 19일
Just do
MAT(MAT == 0) = 6;
  댓글 수: 1
Igina
Igina 2013년 6월 19일
Thanks! I am actually not familiar with such smart solutions!

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by