配列からゼロを取り除くにはどうしたらよいですか?
Show older comments
配列からゼロを取り除きたいと考えています。この配列には各行にちょうど1つのゼロが含まれています。例えば、以下の配列があります。
a = [1 4 0 3; 0 1 5 5; 1 0 8 1; 5 4 4 0; 0 1 5 2]
この配列を次のようにしたいです。
a = [1 4 3; 1 5 5; 1 8 1; 5 4 4; 1 5 2]
a(a==0) = []; というコマンドを試しましたが、2000x50の配列が1x98000の配列になってしまい、2000x49の配列にはなりません。何か良い方法はありますか?
Accepted Answer
More Answers (0)
Categories
Find more on 数値型 in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!