Error in my code

1 回表示 (過去 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 Center および File ExchangeCall C++ from MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by