what bsxfun will perform here?

3 views (last 30 days)
Shan Sha
Shan Sha on 13 Nov 2018
Commented: 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?

Accepted Answer

Star Strider
Star Strider on 13 Nov 2018
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.

More Answers (0)

Categories

Find more on Operators and Elementary Operations in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!