필터 지우기
필터 지우기

How to vectorize this ?

조회 수: 2 (최근 30일)
Alex Kurek
Alex Kurek 2016년 5월 2일
편집: Stephen23 2016년 5월 2일
It seems I dont understand sth about vectorization.
Aj = zeros(1, jCount); % it is filled in reality, but here I just swoh the size
uj = zeros(K, jCount); % as above
for angle = 1:K
currentUj = uj(angle, :);
beta(angle) = sum(Aj.*currentUj);
end
Can somebody show me how to vectorize this, so I can learn what I do wrong?
Best regards, Alex

채택된 답변

Stephen23
Stephen23 2016년 5월 2일
편집: Stephen23 2016년 5월 2일
This does that same as your loop:
beta = sum(bsxfun(@times,Aj,uj),2).';

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by