faster winner takes all
Show older comments
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 Comments
Walter Roberson
on 6 Nov 2011
Your code does not match your written requirements for the situation where S(r,1) is 0.75 exactly (which _is_ possible in binary floating point.)
Dimitris
on 6 Nov 2011
Walter Roberson
on 6 Nov 2011
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 .
Accepted Answer
More Answers (0)
Categories
Find more on Vector Fields in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!