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

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,

 採用された回答

Wayne King
Wayne King 2011 年 12 月 31 日

0 投票

a=[13 1 4; 45 23 1; 1 56 78];
indices = find(a==1);
a(indices) = [];

2 件のコメント

som
som 2011 年 12 月 31 日
thanks for your guidance.
Matt Tearle
Matt Tearle 2011 年 12 月 31 日
Even quicker and cleaner:
a(a==1) = [];

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeResizing and Reshaping Matrices についてさらに検索

質問済み:

som
2011 年 12 月 31 日

Community Treasure Hunt

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

Start Hunting!

Translated by