groupcounts and sum of data in another array in the same order
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
yehuda kristo
el 13 de Dic. de 2023
Editada: Dyuman Joshi
el 13 de Dic. de 2023
I have a random signal sample and I have done cycle counting to extract the data that most influence calculation. The result of this cycle counting are 2 arrays, array A which consist of its range (2 x amplitude) and array B which consist of its occurrence (half cycle or full cycle). I want to do groupcounts that count the occurrence of ranges from array A and count the sum of its cycle from the result of the groupcounts.
Example:
A = [10, 11, 12, 10, 11, 12, 13, 11, 15, 10], B = [0.5, 1, 1, 0.5, 0.5, 0.5, 1, 1, 1, 0.5]
The goupcounts on array A will tell me how much do 10, 11, 12, 13, and 15 occured in array A. I want to count the sum of the cycle of each of this ranges (10, 11, 12, 13, and 15). How do I do that?
1 comentario
Dyuman Joshi
el 13 de Dic. de 2023
Editada: Dyuman Joshi
el 13 de Dic. de 2023
Do you mean like this?
A = [10, 11, 12, 10, 11, 12, 13, 11, 15, 10];
B = [0.5, 1, 1, 0.5, 0.5, 0.5, 1, 1, 1, 0.5]
[I, K] = findgroups(A)
S1 = accumarray(I.', A.')
S2 = accumarray(I.', B.')
Edit - Well, it seems I'm late to the party haha.
Respuesta aceptada
Voss
el 13 de Dic. de 2023
A = [10, 11, 12, 10, 11, 12, 13, 11, 15, 10], B = [0.5, 1, 1, 0.5, 0.5, 0.5, 1, 1, 1, 0.5]
[counts,vals] = groupcounts(A(:))
sums = groupsummary(B(:),A(:),'sum')
0 comentarios
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!