Fixing data set with if/else, how do I index/indicate this properly?
Mostrar comentarios más antiguos
I have a data set of seconds (plotted image below).

Rather than consistently increasing, they are dropping down and resetting. I am trying to write something that fixes this so the end result will be them spaced as they are now but in a consistently increasing line. I think I want to indicate that each time a value v is lower than the previous (v-1), add the difference between the two to v and keep going. I am new to Matlab and started to write something like this:
for v=1:length(Seconds)
if (Seconds(v+1) <= Seconds(v))
Seconds(v+1) = Sec
onds(v+1)+(Seconds(v)-Seconds(v+1));
else
(Seconds(v+1)) = Seconds(v+1);
end
end
How do I properly assign the new values? Thank you
4 comentarios
dpb
el 31 de Oct. de 2018
yy=cumsum(y);
may be what you're looking for?
L
el 31 de Oct. de 2018
dpb
el 31 de Oct. de 2018
Yeah, shorten the file to the first one (or at most two) cycles and show us what you think the answer would be to go with it...afaict, what you've written about is what cumsum does.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Creating, Deleting, and Querying Graphics Objects 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!


