Filter löschen
Filter löschen

transforming a matrix to an array without one values???

1 Ansicht (letzte 30 Tage)
som
som am 31 Dez. 2011
Hi all
I have a matrix having some values equal to one. I want to transform this matrix to an array without the one values.
how can I do this? for example a=[13 1 4; 45 23 1; 1 56 78] changed to b=[13 45 23 56 4 78]
cheers,

Akzeptierte Antwort

Wayne King
Wayne King am 31 Dez. 2011
a=[13 1 4; 45 23 1; 1 56 78];
indices = find(a==1);
a(indices) = [];
  2 Kommentare
som
som am 31 Dez. 2011
thanks for your guidance.
Matt Tearle
Matt Tearle am 31 Dez. 2011
Even quicker and cleaner:
a(a==1) = [];

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by