Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Write a code for repmat; the only built-in commands you are allowed to use ar

ID: 2325576 • Letter: 1

Question

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

Explanation / Answer

%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)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote