Write a scriptthat uses a two-dimensional array A and doubles the size of thearr
ID: 3615696 • Letter: W
Question
Write a scriptthat uses a two-dimensional array A and doubles the size of thearray by replicating each item horizontally, vertically, anddiagonally. You should not use iteration to solve thisproblem. Example:
>> A = [1 4 7; 8 9 3]
< yourscript here >
ans =
1 1 4 4 77
1 1 4 4 77
8 8 5 5 33
8 8 5 5 33
Explanation / Answer
>> A = [1 4 7; 8 9 3]A =1 4 78 9 3>> s = size(A);>> IL = eye(s(1));>> XL = ones(2,1);>> L = kron(IL, XL);>> IR = eye(s(2));>> XR = ones(1,2);>> R = kron(IR,XR);>> L*A*Rans =1 1 4 4 7 71 1 4 4 7 78 8 9 9 3 38 8 9 9 3 3
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.