Finding length between two array elements.
古いコメントを表示
i have an array consisting of 1's and 0's. 1-> generators on and 0's-> generators off. I need to find lengths for which the generators remain off. the array is 44*8760 values. Attaching the file as worspace.
5 件のコメント
Hank
2019 年 12 月 3 日
Could you describe what you mean by the lengths?
Hrishikesh Dalal
2019 年 12 月 3 日
David Goodmanson
2019 年 12 月 3 日
編集済み: David Goodmanson
2019 年 12 月 3 日
HI Hrishikesh,
for a single row of values x,
z = diff(find(diff([inf x inf])))
za = z(1:2:end)
zb = z(2:2:end)
gives a set of 'on' lenghts and a set of 'off' lengths. Which is which,
depends on whether x starts off with a 0 or a 1. With the aid of a small example you can work that out.
Hrishikesh Dalal
2019 年 12 月 3 日
David Goodmanson
2019 年 12 月 3 日
Hrishikesh,
I posted the wrong expression for z in the comment but it is fixed now.
回答 (1 件)
the cyclist
2019 年 12 月 3 日
0 投票
カテゴリ
ヘルプ センター および File Exchange で Structures についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!