フィルターのクリア

I want to remove zeroes from an array. The array more zero per row. For example: a = [200.03 303.56 0 0 0; 155.23 0 0] Should be turned into a = [200.03 303.56; 155.23]

1 回表示 (過去 30 日間)
Sarumathi C
Sarumathi C 2018 年 3 月 14 日
回答済み: KSSV 2018 年 3 月 14 日
I want to remove zeroes from an array. The array has exactly mote zero per row. For example:
a = [1 4 3 0 0 0; 1 5 0 0 0; 1 8 1 0 0; 5 4 4 0 0;1 5 2 0 0]
Should be turned into
a = [1 4 3; 1 5 5; 1 8 1; 5 4 4; 1
  1 件のコメント
KSSV
KSSV 2018 年 3 月 14 日
a = [1 4 3 0 0 0; 1 5 0 0 0; 1 8 1 0 0; 5 4 4 0 0;1 5 2 0 0]
This is not correct......please correct your question properly.

サインインしてコメントする。

回答 (1 件)

KSSV
KSSV 2018 年 3 月 14 日
a = [1 4 3 0 0 0 1 5 0 0 0 1 8 1 0 0 5 4 4 0 0 1 5 2 0 0]
% b = [1 4 3 1 5 5 1 8 1 5 4 4 1 ] ;
b = a ;
b(a==0) = [] % remove zeros
b = a ;
b(b~=0) % pick non zeroes

カテゴリ

Help Center および File ExchangeImages についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by