while loop performance improvement
1 回表示 (過去 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 で Environment and Clutter についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!