Compute different length mean when cell equals number
Mostra commenti meno recenti
I need to compute the mean of "x" number of rows in a column of data when a cell in another column is repeated. For example: I have the 2 columns of data:
A = (23, 23, 24, 25, 25, 25, 26, 26, 27, 27, 27, 27) and
B = ( 42, 43, 44, 38, 35, 36, 32, 28, 45, 46, 38, 29).
If a number repeats in "A" I need to get the mean of the value in the same row from "B". If it does not repeat, then the mean can just be the single number. An example output would be the mean in each cell like so:
Output = 42.5, 42.5, 44, 36.3, 36.3, 36.3, 30, 39.5, 39.5, 39.5, 39.5).
I have tried doing this with a while loop, but I'm relatively new to Matlab and haven't had much luck.
1 Commento
Geoff Hayes
il 13 Ott 2016
Tyler - is it safe to assume that the elements of A are ordered like the above such that all identical numbers are grouped together?
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Hypothesis Testing in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!