How to eliminate zeros from array

e.g I want to make this:
1,1,1,1,0,0 1,1,0,0,0,0 1,0,0,0,0,0 1,1,1,1,1,0 into this:
1,1,1,1 1,1 1 1,1,1,1,1

1 件のコメント

Jos (10584)
Jos (10584) 2018 年 3 月 14 日
Can you give a an example of these two arrays in working matlab code?
Array1 = ...
Array2 = ...

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

回答 (1 件)

Jos (10584)
Jos (10584) 2018 年 3 月 14 日

0 投票

a(~logical(a)) = []

5 件のコメント

Sarumathi C
Sarumathi C 2018 年 3 月 14 日
Sir the all values coming in single column but I need location of non zero values not change and only zeros should be eliminated to find difference between two rows when both row have same number of non zero values
Jos (10584)
Jos (10584) 2018 年 3 月 14 日
You cannot simply eliminate elements in a regular array without changing the shape, you should replace them by something else.
What do you exactly mean by " find difference between two rows " ?
Sarumathi C
Sarumathi C 2018 年 3 月 14 日
My output like 2 0 0 0; 5 5 0 0; 6 7 0 0; 1 5 8 0; I need to covert like 2; 5 5; 6 7; 1 5 8; I need to find out the difference between the 2nd row and 3rd row because 1St have different length comparing with second row but 2&3 have same length of values so I need output like 2; 1{(6-5)} {(7-2)} 2; 1 5 8;
Jos (10584)
Jos (10584) 2018 年 3 月 14 日
Please use valid matlab notation for the examples ...
Birdman
Birdman 2018 年 3 月 14 日
編集済み: Birdman 2018 年 3 月 14 日
And maybe this should be a new question since it is hard to pay attention to this between comments, also you are off the topic of the question.

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

カテゴリ

製品

質問済み:

2018 年 3 月 14 日

編集済み:

2018 年 3 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by