I have matrix M=[ 0 0 0 7.9286 10.1000 14.3714]
I want to delete null in matrix.
I want matrix M=[7.9286 10.1000 14.3714]
Thanks

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 12 月 14 日
編集済み: Azzi Abdelmalek 2013 年 12 月 14 日

0 投票

M=[ 0 0 0 ; 7.9286 10.1000 14.3714]
M=M(all(M,2),:)

3 件のコメント

Tomas
Tomas 2013 年 12 月 14 日
i can have for example also M=[ 0 0 0; 1 2 3; 0 0 0; 7 8 9; 1 2 3] I want only M=[ 1 2 3; 7 8 9; 1 2 3] Thanks
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 12 月 14 日
Still works
M=M(all(M,2),:)
Tomas
Tomas 2013 年 12 月 14 日
Ok, Thanks

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

その他の回答 (1 件)

sixwwwwww
sixwwwwww 2013 年 12 月 14 日

0 投票

do it like this:
M=[ 0 0 0 7.9286 10.1000 14.3714];
M = M(M ~= 0)

5 件のコメント

Tomas
Tomas 2013 年 12 月 14 日
編集済み: Azzi Abdelmalek 2013 年 12 月 14 日
M=[ 0 0 0 ; 7.9286 10.1000 14.3714]
your solution
M[7.9286;
10.1;
14.3714]
i need
M=[7.9286 10.1000 14.3714] if row vector
Thanks
sixwwwwww
sixwwwwww 2013 年 12 月 14 日
do it as follow:
M = [0 0 0 7.9286 10.1000 14.3714];
M = (M(M ~= 0))'
Also I like to ask you do you have values in a matrix or in just in a vector
Tomas
Tomas 2013 年 12 月 14 日
編集済み: Tomas 2013 年 12 月 14 日
i have values in matrix
sixwwwwww
sixwwwwww 2013 年 12 月 14 日
do you want to convert them to a column vector of non-zero values?
Tomas
Tomas 2013 年 12 月 14 日
yes

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

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

タグ

質問済み:

2013 年 12 月 14 日

コメント済み:

2013 年 12 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by