Can you help me understand this code?

1 次查看(过去 30 天)
nc
nc 2016-11-4
编辑: nc 2016-11-4
....
  1 个评论
Adam
Adam 2016-11-4
Which parts of it are you struggling with in particular? There is nothing out of the ordinary in there that isn't in the help.

请先登录,再进行评论。

回答(1 个)

John D'Errico
John D'Errico 2016-11-4
编辑:John D'Errico 2016-11-4
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');

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by