필터 지우기
필터 지우기

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 CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by