help for vectorization coding for multiplication and addition matrixs

1 回表示 (過去 30 日間)
reshdev
reshdev 2014 年 9 月 6 日
編集済み: reshdev 2014 年 11 月 10 日
Hello,
I have two separate codes.
Use of for loops for following codes making them too heavy , so they are taking too long for bigger size matrix's. can anyone please help me to write both in vectorized form.
Thanks
CODE 1---
Ft= zeros(n,n);
for row=1:na
for col =1:nv
tn(row,col)= st(row,col)*y(row,col);if y(row,col)>0
tn(row,col) = tn(row,col)+ff(row,col);
end
end
end

採用された回答

Roger Stafford
Roger Stafford 2014 年 9 月 6 日
編集済み: Roger Stafford 2014 年 9 月 6 日
Try this:
Fn = cost.*W+(W>0).*FC;
and
W = sum(reshape(outp(:,1:n*dr,u),[],n,dr),3);
(I assume u is a scalar index here.)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by