Effacer les filtres
Effacer les filtres

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

3 vues (au cours des 30 derniers jours)
benghenia aek
benghenia aek le 26 Nov 2021
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

Réponses (2)

Walter Roberson
Walter Roberson le 26 Nov 2021
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 le 27 Nov 2021
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.

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by