Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
n = 10;
m = 4;
y = random_binary(n,m);
assert(islogical(y) && isequal(sum(y),m) && abs(std(diff(y)>0)-0.45)<0.2)

                    
2
Pass
 
%%
n = 1000;
m = 500;
y = random_binary(n,m);
assert(islogical(y) && isequal(sum(y),m) && abs(std(diff(y)>0)-0.45)<0.05)

                    
3
Pass
 
%%
n = 500;
m = 20;
y = random_binary(n,m);
assert(islogical(y) && isequal(sum(y),m) && abs(std(diff(y)>0)-0.18)<0.05)