using a for loop to find the mean of a set of data
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Kacey Lange
el 26 de Jul. de 2022
Comentada: Matt J
el 26 de Jul. de 2022
I am trying to use a for loop to find the mean of of the first and eigth row of data, second and ninth row of data, third and tenth row of data, ect ect until I reach the seventh and fourteeth row of data. I have a 84x1 double and so my output i am expecting is a 42x1 double as I have 6 sets of data. I have tried somethign similar to this:
out = splitapply(@mean,TSMo,ceil((1:numel(TSMo))'/7));
My matrix is TSMo. But that averages every 1-7 rows.
0 comentarios
Respuesta aceptada
Matt J
el 26 de Jul. de 2022
Editada: Matt J
el 26 de Jul. de 2022
out = mean( reshape(TSMo,7,2,6) ,2);
out=out(:);
3 comentarios
Matt J
el 26 de Jul. de 2022
Assuming the magic jump interval is always 7, you can do,
out = mean( reshape(TSMo,7,2,[]) ,2);
Otherwise, you must add parameters to your code for the jump interval.
Más respuestas (1)
Ver también
Categorías
Más información sobre Loops and Conditional Statements 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!