Please write in MatLab Code. Thank you r0 1 0 0 2 0 10 0 0 0 0] PROBLEM 1: Use M
ID: 3282669 • Letter: P
Question
Please write in MatLab Code. Thank you
r0 1 0 0 2 0 10 0 0 0 0] PROBLEM 1: Use MATLAB commands to write the matrix:S-[0 0 12 0|as the sum of two matrices having non-zero entries on different diagonals. Hint: help diag. a) Compute S* for k-2.3,4. Describe in words what happens when computing Sk b) By using this reasoning, what do you expect S30 to be? c) As part of a linear algebra quiz, your friend answers TRUE to the question: Is it true or false that : If A B-0 then one of the matrices A or B is the zero matrix? Based on your computations above, do you agree?Explanation / Answer
MATLAB code
close all
clear
clc
S = [0 1 0 0 2;
0 0 7 0 0;
0 0 0 12 0;
0 0 0 0 3;
0 0 0 0 0]
% Sum of two matrices having
% non-zero entries on different diagonals
S1 = S + diag(ones(1,5))
S2 = diag(-ones(1,5))
fprintf(' Part (a) ');
disp('S^2:'), disp(S^2)
disp('S^3:'), disp(S^3)
disp('S^4:'), disp(S^4)
fprintf(' Part (b) ');
% So, S^30 would be a zero matrix
disp('S^30')
disp(S^30)
% Part (c)
% Since, S^4 * S will be a zero matrix,
% and none of S^4 and S are zero matrices,
% the answer would be 'FALSE'.
Output
S =
0 1 0 0 2
0 0 7 0 0
0 0 0 12 0
0 0 0 0 3
0 0 0 0 0
S1 =
1 1 0 0 2
0 1 7 0 0
0 0 1 12 0
0 0 0 1 3
0 0 0 0 1
S2 =
-1 0 0 0 0
0 -1 0 0 0
0 0 -1 0 0
0 0 0 -1 0
0 0 0 0 -1
Part (a)
S^2:
0 0 7 0 0
0 0 0 84 0
0 0 0 0 36
0 0 0 0 0
0 0 0 0 0
S^3:
0 0 0 84 0
0 0 0 0 252
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
S^4:
0 0 0 0 252
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
Part (b)
S^30
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0