Discover MakerZone

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

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!

Correct

15000Size
Leading solution size is 16.
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
 
%%
feval(@assignin,'caller','score',0);

					

	    	
2
Pass
 
%%
% Testing for standard repmat capability
a=magic(5);
M=randi(4);
N=randi(8);
assert(isequal(repmat(a,M,N),repmatLV(a,M,N)));
a=5;
M=randi(10);
N=randi(10);
assert(isequal(repmat(a,M,N),repmatLV(a,M,N)));
a=5;
M=randi(10);
N=1;
assert(isequal(repmat(a,M,N),repmatLV(a,M,N)));
a=4;
M=1;
N=randi(10);
assert(isequal(repmat(a,M,N),repmatLV(a,M,N)));
a=magic(8);
M=2;
N=2;
assert(isequal(repmat(a,M,N),repmatLV(a,M,N)));

					

	    	
3
Pass
 
%%
M=1024;
N=1;
n=48;
r=randi(255,1,n,'uint8');
%r=double(r);
for i=1:5  % Routine warm-up
  r_repmatLV=repmatLV(r,M,N);
end
clear r_repmatLV
P1=false; P2=false; P3=false;P4=false;
M=6144000;
N=4;
n=12;
r=randi(2^31,1,n,'uint32');
ta=clock;
 r_repmatLV=repmatLV(r,M,N);
t1=etime(clock,ta)*1000;
P1=isequal(r(1,12),r_repmatLV(M,n*N));
P2=isequal(r(1,12),r_repmatLV(randi(10000),36));
assert(P1 && P2  && ~ P3  && ~P4)
clear r_repmatLV
P1=false; P2=false; P3=false;P4=false;
M=6144000;
N=16;
n=12;
r=randi(255,1,n,'uint8');
tb=clock;
 r_repmatLV=repmatLV(r,M,N);
t2=etime(clock,tb)*1000;
P2=isequal(r(1,12),r_repmatLV(M,n*N));
assert(P2 && ~P1  && ~ P3  && ~P4)
clear r_repmatLV
P1=false; P2=false; P3=false;P4=false;
M=6144000;
N=1;
n=48;
r=randi(2^31,1,n,'uint32');
tc=clock;
 r_repmatLV=repmatLV(r,M,N);
t3=etime(clock,tc)*1000;
P3=isequal(r(1,1),r_repmatLV(M,1));
assert(P3 && ~P1  && ~ P2  && ~P4)
clear r_repmatLV
P1=false; P2=false; P3=false;P4=false;
M=12288000;
N=1;
n=48;
r=randi(255,1,n,'uint8');
td=clock;
 r_repmatLV=repmatLV(r,M,N);
t4=etime(clock,td)*1000;
P4=isequal(r(1,48),r_repmatLV(1000000,48));
assert(P4 && ~P3  && ~ P2  && ~P1)
clear r_repmatLV
% This checks for sub-optimal column processing
P1=false; P2=false; P3=false;P4=false;
M=64;
N=1;
n=4000000;
r=randi(255,1,n,'uint8');
te=clock;
 r_repmatLV=repmatLV(r,M,N);
t5=etime(clock,te)*1000;
P5=isequal(r(1,n),r_repmatLV(M,n));
assert(P5)
feval(@assignin,'caller','score',0);
if P5
 sum_dt=min(15000,t1+t2+t3+t4+t5); % repmat scores 12000
 feval(@assignin,'caller','score',floor(sum_dt));
end
fprintf('Times: %.0f %.0f %.0f %.0f %.0f  Total %.0f msec\n',t1,t2,t3,t4,t5,t1+t2+t3+t4+t5)
Times: 8613 5910 2186 2684 637  Total 20030 msec