delete null in matrix

22 Ansichten (letzte 30 Tage)
Tomas
Tomas am 14 Dez. 2013
Kommentiert: Tomas am 14 Dez. 2013
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

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 14 Dez. 2013
Bearbeitet: Azzi Abdelmalek am 14 Dez. 2013
M=[ 0 0 0 ; 7.9286 10.1000 14.3714]
M=M(all(M,2),:)
  3 Kommentare
Azzi Abdelmalek
Azzi Abdelmalek am 14 Dez. 2013
Still works
M=M(all(M,2),:)
Tomas
Tomas am 14 Dez. 2013
Ok, Thanks

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

sixwwwwww
sixwwwwww am 14 Dez. 2013
do it like this:
M=[ 0 0 0 7.9286 10.1000 14.3714];
M = M(M ~= 0)
  5 Kommentare
sixwwwwww
sixwwwwww am 14 Dez. 2013
do you want to convert them to a column vector of non-zero values?
Tomas
Tomas am 14 Dez. 2013
yes

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by