Can you help me understand this code?
2 ビュー (過去 30 日間)
古いコメントを表示
回答 (1 件)
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');
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!