Write a function with the header: function [mOuter, mInner] myInnerOuterMatrix (
ID: 3754975 • Letter: W
Question
Write a function with the header: function [mOuter, mInner] myInnerOuterMatrix (M) which M is a matrix which is at least (3x3), mOuter is a matrix of the same size of M which contains the boundary elements of M and zeros everywhere else and minner is a matrix of the same size of M which contains the inner elements of M and zeros on the boundary Test Cases >M 1 2 3:4 5 6:7 8 9 >>[m1, m2] -myInnerouterMatrix (M) ml- 1 2 6 0 0 0 >format short >m4-rand (7,7) m4- 0.7547 0.9597 0.6991 0.8407 0.2511 0.9172 0.0540 0.2760 0.3404 0.8909 0.2543 0.6160 0.2858 0.5308 0.8143 0.2435 . 67 97 0.6551 0.585 0.2238 0.9593 0.5472 0.4733 0.3517 0.7572 0.7537 0.7792 . 9340Explanation / Answer
function [mOuter, mInner] = myInnerOuterMatrix(M) [r, c] = size(M); for i=1:r for j=1:c if i == 1 || j == 1 || i == r || j == c mOuter(i, j) = M(i, j); mInner(i, j) = 0; else mOuter(i, j) = 0; mInner(i, j) = M(i, j); end end end end
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.