How to make calculations over an interval throughout an entire vector?

1 visualización (últimos 30 días)
Anonymous
Anonymous el 29 de Nov. de 2018
Comentada: Star Strider el 29 de Nov. de 2018
I have a vector, say "Voltage" and it's 400 elements long. I want to calculate the min and max every 100 indicies and store that in a vector. How can I do that? I was thinking a for loop would be what I want, but I don't know how to make the loop scan the entire Voltage vector and make the min and max calculations every 100 indicies. Would it be a nested loop?

Respuestas (1)

Star Strider
Star Strider el 29 de Nov. de 2018
I would use the movmax function and its friends, or if you want to calculate the maximum or minimum over 100-element blocks of your vector, use the reshape function. Note that reshape requires that your vector be an integer multiple of 100 elements, or that you truncate it to meet that criterion.
  6 comentarios
Anonymous
Anonymous el 29 de Nov. de 2018
finding the mean over the same invtervals throughout the vector
Star Strider
Star Strider el 29 de Nov. de 2018
Take the mean of the matrix my code creates. It will automatically take the mean of the columns.

Iniciar sesión para comentar.

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by