Finding an average of 1XN vector using iteration.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I am trying iterate a 1xN vector but I am having a hard time setting up the loop for the question below.
To do this, find the initial mean of the input vector, then remove 10 values off the front of that vector; find a second mean of the shortened vector, then calculate the relative change between those two mean values. Then treat the shortened vector as the original, and repeat those steps until the relative change is less than or equal to 0.0005.
3 comentarios
dpb
el 18 de Feb. de 2015
OK, after you've gotten the two averages, you need to then test the magnitude of the difference against the criterion for stopping (which you've not yet included anywhere and then, if it's less or equal you're done; otherwise set
avg1=avg2;
before the loop begins again...
I'll leave actual code mod's for you make and then we can look at next iteration of it, too... :)
Respuestas (0)
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!