1 Write a code for repmat the only builtin commands you are
1. Write a code for repmat; the only built-in commands you are allowed to use are input, size, and disp. The question wants you to write code to do the same thing that repmat command does All of this done in MATLAB
I have this so far
Repmata = input( \'Enter data elements a:\ \' );
x = input( \'to repeat your rows:\ \' );
y = input( \'to repeat your column:\ \' );
[row,col] = size(a);
for i = 0:x
for j = 0:y
for r = 1:row
for k = 1:col
b(r+(row*(i-1)),k+(col*(j-1))) = a(r,k);
end
end
end
end
disp(b)
It tells me that b changes size in every loop
i am trying to get this code to work
Solution
%Check the program
disp(\'Repmdata\')
a = input( \'Enter data elements a:\ \' );% The total of elements of matrix A
x = input( \'to repeat your rows:\ \' );%Rows number
y = input( \'to repeat your column:\ \' );%Columns number
[row,col] = size(a);
for i = 1:x
for j = 1:y
for r = 1:row
for k = 1:col
b(r+(row*(i-1)),k+(col*(j-1))) = a(r,k);
end
end
end
end
disp(\'Matrix A=\')
disp(b)
