Better syntax than for loop
6 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Azzi Abdelmalek
2014-1-18
编辑:Azzi Abdelmalek
2014-1-18
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')
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!