MATLAB Answers

0

what bsxfun will perform here?

Asked by Shan Sha on 13 Nov 2018
Latest activity Commented on by Star Strider
on 13 Nov 2018
function Ccode = gen_binary_codes(C, K)
U=mean(C,1);
Ccode =zeros(size(C));
Ccode( bsxfun(@gt, C, K*U) )=1;
This is my code. what bsxfun is performing here?

  0 Comments

Sign in to comment.

Tags

1 Answer

Answer by Star Strider
on 13 Nov 2018
 Accepted Answer

The bsxfun call calculates a vector of logical elements.
If ‘C’ is greater than ‘K*U’, the output is true, and the expression sets the elements of ‘Ccode’ corresponding to those logical true subscripts equal to 1.

  2 Comments

Shan Sha on 13 Nov 2018
thanks sir
Star Strider
on 13 Nov 2018
As always, my pleasure.

Sign in to comment.