(Solved):Write a code for repmat; the only built-in commands you are allowed to use are input, size, and disp. View Answer…

 

Question

Write a code for repmat; the only built-in commands you are allowed to use are input, size, and disp.

 

EXPERT ANSWER

Coding

function B=repimat(A,a,b)
[m,n]=size(A);
row=m*a;
col=n*b;
B=zeros(row,col);
for i=1:a
for j=1:b
for x=1:m
for y=1:n
B(((i-1)*m)+x,((j-1)*n)+y)=A(x,y);
end
end
end
  
end
A=[[1 2];[3 4]];
B=repimat(A,2,2);
disp

We are so grateful for the pleasure of serving you and hope we met your expectations. Thank you. Manvila.

Scroll to top