Using Matlab Create a matrix B using submatrices made up of
Using Matlab. Create a matrix B using submatrices made up of elementary matrices: one, zeros and identity matrix of the special sizes. And show the diagonal of matrix B in a row vector without transpose.
Solution
b1=eye(4,4);
b2=ones(4,4);
b3=zeros(4,4);
B=cat(2,b1,b2,b3); %concantanating the elemantary matices to create B
B6=B(:,6)-B(:,5); % column transformation
B7=B(:,7)-B(:,5);% column transformation
B8=B(:,8)-B(:,5);% column transformation
B5=B(:,5)-B(:,1)-B(:,2)-B(:,3)-B(:,4);% column transformation
B2=B(:,2)-B(:,1); % column transformation
B3=B(:,3)-B(:,1); % column transformation
B4=B(:,4)-B(:,1); % column transformation
Bnew=cat(2,B(:,1),B2,B3,B4,B5,B6,B7,B8,B(:,9:end));% concantanating to get a diagonal matrix
Bnew2=Bnew(2,:)+Bnew(1,:); % row transformation
Bnew3=Bnew(3,:)+Bnew(1,:); % row transformation
Bnew4=Bnew(4,:)+Bnew(1,:); % row transformation
BB=cat(1,B(1,:),Bnew2,Bnew3,Bnew4);%concatanation
R=diag(BB); % this matrix is a 1x1 matrix so it has no transform
Y=R\';
