omit zeros from matrix and have the shape of matrix

1 回表示 (過去 30 日間)
NA
NA 2019 年 4 月 14 日
回答済み: Kevin Rawson 2019 年 4 月 14 日
A=[0,0;0,0;0,0;1,2;2,5;5,7;7,8];
I want to omit zero from this matrix. result should be
New_A=[1,2;2,5;5,7;7,8];
I use this code
A(A==0) = [];
But giving me array.

採用された回答

Kevin Rawson
Kevin Rawson 2019 年 4 月 14 日
If you are trying to get rid of rows with zeros:
A(all(A == 0, 2), :) = [];

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by