Better syntax than for loop

8 ビュー (過去 30 日間)
Tracy
Tracy 2014 年 1 月 18 日
コメント済み: Tracy 2014 年 1 月 18 日
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

採用された回答

Azzi Abdelmalek
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')
  1 件のコメント
Tracy
Tracy 2014 年 1 月 18 日
Thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by