Accumulating data in a loop while
Mostrar comentarios más antiguos
Good evening, I need to collect data into an array with accumulation.
For example, there are 9 time values t=9, the array should look like this (0 t1 t1+t2 t1+t2+t3 and...) I want to do this in a loop so that it would be possible to regulate the number of t values.
So far I've thought of this, but it doesn't work correctly:
index=1;
n=10;
c=[];
while index<10
t = b(index)+b(index+1)
if t>b(index) && index<10
t1=0;
t1 = t + b(index)
index=index+1;
end
c=[c t1];
end
c
3 comentarios
Dyuman Joshi
el 29 de En. de 2024
Few things -
"b" is not defined.
You initialize "t1" as zero, but then over-write in the next line, which does not makes sense to me.
What are you trying to do? What is the objective? What is the code suppose to do?
You have added the tag "database" for this question - How does a database come into this question?
gravy
el 29 de En. de 2024
gravy
el 29 de En. de 2024
Editada: Walter Roberson
el 29 de En. de 2024
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!