Can you help me understand this code?

조회 수: 9 (최근 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