function []=hw5_2_16(A,B) % find e-vals of block matrix of (optional inputs) A and B % I have A and B as input just cause I wanted to play around with other matrices % default values of A and B if nargin<2 A=[1,2,2; 5,6,-2; 1,-1,0]; B=[2,0,1; 4,-5,1; 1,0,0]; end % if other A and B are entered make sure it'll work [n1,n2]=size(A); [n3,n4]=size(B); if ~(n1==n2)|~(n2==n3)|~(n3==n4) break end C=[A,B;B,A]; disp('e-vals of C (sorted)') disp(sort(eig(C))) disp('e-vals of A+B') e1=eig(A+B); disp(e1) disp('e-vals of A-B') e2=eig(A-B); disp(e2) disp('e-vals of A+B and A-B (sorted together)') disp(sort([e1;e2]))