フィルターのクリア

Vectorizing nested for loops

3 ビュー (過去 30 日間)
William
William 2011 年 6 月 30 日
Hello, I'm relatively new to Matlab and am having some difficulties vectorizing my code. Although I'm sure that the answer to my question exists somewhere, I confess that I haven't yet found it. Anyway, I'm trying to vectorize the following nested for loops: for i=2:rho {for|j=1:zDim {phi(i,j) = phi(1,j)/(1+i)}}
It's certainly just a rookie question, but I appreciate any advice.

採用された回答

Andrei Bobrov
Andrei Bobrov 2011 年 6 月 30 日
bsxfun(@rdivide,phi,(1+(2:rho))')
here phi vector row
or use first row of 'phi' matrix
bsxfun(@rdivide,phi(1,:),(1+(2:rho))')
  1 件のコメント
William
William 2011 年 6 月 30 日
Thank you! I appreciate it.

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

その他の回答 (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