How to convert a matrix like this?

Hello everyone, I need a help with this problem. I would like to convert a matrix to another one, like the following examples: A=[1;2;3;0;5;7]----->A=[1;2;3;5;7] B=[0;1;3;4;5;6]---->B=[1;3;4;5;6] That means I have a new matrix without 0. Thank you very much!

 採用された回答

madhan ravi
madhan ravi 2018 年 9 月 4 日
編集済み: madhan ravi 2018 年 9 月 4 日

0 投票

Try this:
A(A==0)=[]

6 件のコメント

madhan ravi
madhan ravi 2018 年 9 月 4 日
If it works please accept the answer.
Phung Minh
Phung Minh 2018 年 9 月 4 日
Thank you so much!???
madhan ravi
madhan ravi 2018 年 9 月 4 日
You're welcome :)
Guillaume
Guillaume 2018 年 9 月 4 日
A much simpler way:
A = nonzeros(A)
madhan ravi
madhan ravi 2018 年 9 月 4 日
Thank you @Guillaume :)
Phung Minh
Phung Minh 2018 年 9 月 4 日
Thank you ?

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by