while loop performance improvement
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Fabio Freschi
le 17 Nov 2019
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
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Environment and Clutter dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!