Can you help me understand this code?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Respuestas (1)
John D'Errico
el 4 de Nov. de 2016
Editada: John D'Errico
el 4 de Nov. de 2016
It looks like a poorly written (and wholly uncommented, which makes it very poor IMHO) code to compute a cumulative mean, then keeping track of the last time that mean falls below the value avg-0.01. This is the problem with poorly written code. Hard to read. Hard to follow. Often buggy as hell.
In two lines, three if you count the assignment of the vector k:
cumavg = cumsum(k)./(1:numel(k));
mark = find(cumavg <= (avg - 0.01),1,'last');
0 comentarios
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!