while loop performance improvement
조회 수: 3 (최근 30일)
이전 댓글 표시
Hello everyone,
What is the alternative of while loop for the example:
rate = 2;
while (k <= period)
sum = sum + array(k,2);
k = k + rate;
end
Thanks.
댓글 수: 0
채택된 답변
Fabio Freschi
2019년 11월 17일
I don't know the starting value of k, assuming it is 1
idx = 1:rate:period
mysum = sum(array(idx,2)); % note that sum is the name of a matlab function
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Legend에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!