필터 지우기
필터 지우기

faster winner takes all

조회 수: 2 (최근 30일)
Dimitris
Dimitris 2011년 11월 6일
I 've made an mplementation of the winner takes all rule (WTA) using a for loop (code bellow). But now I want to "harden" ~8 million values and the loop is very slow (several hours). Any idea for a faster WTA implementation? In detail, if we have a matrix with values in [0,1] we need to replace them with 1 for > 0.75 or with 0 for < 0.75.
function H = wta(S)
% Winner Takes All (WTA) rule
% returns the hard values for S
%
[row,col] = size(S);
for r = 1:row
if S(r,1) > 0.75
H(r,1) = 1;
else
H(r,1) = 0;
end
end
  댓글 수: 3
Dimitris
Dimitris 2011년 11월 6일
Correct, it is just that 0.75 is so arbitrary that it does not matter which way is goes. You are correct mathematically though.
Walter Roberson
Walter Roberson 2011년 11월 6일
For 0.75 exactly, as you do not define any replacement conditions, the implication would be that those locations should not be replaced, leaving them 0.75 .

댓글을 달려면 로그인하십시오.

채택된 답변

Andrei Bobrov
Andrei Bobrov 2011년 11월 6일
  댓글 수: 2
Walter Roberson
Walter Roberson 2011년 11월 6일
H = S(:,1) > 0.75;
would be a closer match to the code. The difference would be important if S is two-dimensional or S is a row vector.
Dimitris
Dimitris 2011년 11월 6일
Many thanks.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Propagation and Channel Models에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by