Better syntax than for loop

11 vues (au cours des 30 derniers jours)
Tracy
Tracy le 18 Jan 2014
Commenté : Tracy le 18 Jan 2014
I've been told that I should avoid "for" loops in MatLab because they are generally less efficient. True? Is there a better way to write this?
for y=1:33
VKT_SC(y,:)=SC_Share(y,:).*Total_F_VKT(y)
end

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 18 Jan 2014
Modifié(e) : Azzi Abdelmalek le 18 Jan 2014
VKT_SC=bsxfun(@times,SC_Share,Total_F_VKT)
or depending on the size of Total_F_VKT
VKT_SC=bsxfun(@times,SC_Share,Total_F_VKT')
  1 commentaire
Tracy
Tracy le 18 Jan 2014
Thanks!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by