フィルターのクリア

find number of zeros in an array

2 ビュー (過去 30 日間)
Harshitha Eshwar
Harshitha Eshwar 2021 年 12 月 10 日
コメント済み: Rik 2021 年 12 月 10 日
data = [ 0 0 0 1 1 0 0 0 0 0 0 1 1 1]
%need the outpout as : length of each zero= (3,6) length of each ones = (2,4)
  1 件のコメント
Harshitha Eshwar
Harshitha Eshwar 2021 年 12 月 10 日
Data = ( 0 0 0 1 1 0 0 0 0 0 0 1 1 1 1)
Need 2 seperate array outputs as Low = (3 6) High = (2 4)

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

採用された回答

Rik
Rik 2021 年 12 月 10 日
Get the RunLength function by Jan from the file exchange.
  2 件のコメント
Harshitha Eshwar
Harshitha Eshwar 2021 年 12 月 10 日
I need to seperate them as Zeros (3,6) Ones (2,4)
Rik
Rik 2021 年 12 月 10 日
You can use the second output to do that (the m-file version will work as well). Just add RunLength with the AddOn Manager, or download it here.
data = [ 0 0 0 1 1 0 0 0 0 0 0 1 1 1];
[out1, out2] = RunLength(data)
out1 = 1×4
0 1 0 1
out2 = 4×1
3 2 6 3
Z=out2(out1==0),O=out2(out1==1)
Z = 2×1
3 6
O = 2×1
2 3

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeText Files についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by