how to find index of 50% of sum of signal?

2 ビュー (過去 30 日間)
benghenia aek
benghenia aek 2021 年 11 月 26 日
回答済み: Image Analyst 2021 年 11 月 27 日
how to find index of 50% of sum of signal
a=[4 2 3 1 5 6 11];
sum(a)=32
50% of sum signal =16
indice which is approximately equal to of sum of 50% of sum signal a is 5

回答 (2 件)

Walter Roberson
Walter Roberson 2021 年 11 月 26 日
Hint:
4, 2, 3, 1, 5, 6, 11
4, 4+2, 4+2+3, 4+2+3+1, 4+2+3+1+5, 4+2+3+1+5+6, 4+2+3+1+5+6+11 -->
4, 6, 9, 10, 15, 21, 32
4<=32/2, 6<=32/2, 9<=32/2, 10<=32/2, 15<=32/2, 21<=32/2, 32<=32/2 -->
true, true, true, true, true, false, false
1 2 3 4 5

Image Analyst
Image Analyst 2021 年 11 月 27 日
Isn't this a duplicate?
If it's not your homework, you can use my solution:
a=[4 2 3 1 5 6 11];
s = sum(a)
c = cumsum(a)
[minDiff, index] = min(abs(c - s/2))
If it is your homework, tag it as homework and find a different way.

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by