You are on page 1of 2

% Zohaib

% BSAP 8th, Sec B


% Assignment No.10
clc
clear all
close all
x=menu('Types of Matrix
Commands','blkding','diag','cat','flip','triangular','rot90');
if x==1;
disp('Command for Changing the values of Diagonal')
A = eye(4)
blkdiag(5,7,11,12)

elseif x==2;
disp('Diagonal')
x1=menu('Types of Diagonal','K=0','K=1','K=2','K=-1','K=-2');
B = [9 7 8 ; 5 2 1 ; 4 2 7 ];
if x1==1;
diag(B,0)
elseif x1==2;
diag(B,1)
elseif x1==3;
diag(B,2)
elseif x1==4;
diag(B,-1)
elseif x1==5;
diag(B,-2)

end
elseif x==3;
disp('Concatenate arrays')
x2=menu('Types','horzcat','vertcat');
M1 = input('Enter the value of Matrix One M1 = ');
M2 = input('Enter the value of Matrix Two M2 = ');
[r1,c1]=size(M1);
[r2,c2]=size(M2);
if r1==r2 && c1~=c2
M3=horzcat(M1,M2);
M4=horzcat(M2,M3)
elseif r1~= r2 && c1==c2;
disp('Number of rows not equal')
M5=vertcat(M1,M2);
M6=vertcat(M2,M5)
end
elseif x==4;
disp('Flip')
x3=menu('Types of Flip','Fliplr','Flipud');

M7=input('Enter the Matrix One = ');


if x3==1;
disp('Flip left to right')
M8=fliplr(M7)

1
elseif x3==2;
disp('Flip up to down')
M9=flipud(M7)
end
elseif x==5;
disp('tril')
x4=menu('Types of triangular Matrix','tril','triu');
M10=input('Enter the Matrix value = ');
if x4==1;
disp('Tril')
K=input('Enter the value of K for choosing diagonal ')
M11=tril(M10,K)
elseif x4==2;
disp('triu')
K1=input('Enter the value of K1 for choosing diagonal ')
M12=triu(M10,K1)
end
elseif x==6 ;
disp('rotation with 90')
x5=menu('Rotation with different Angles','Clockwise ','Anti-
clockwise');

if x5==1;
x6=menu('Clockwise','k=-1','k=-2','k=-3','k=-4');
k=input('Enter the value of k = ');
M13=input('Enter the matrix value = ');
M14=rot90(M13,k)
elseif x5==2;
x7=menu('Clockwise','k1=-1','k1=-2','k1=-3','k1=-4');
k1=input('Enter the value of k1 = ');
M15=input('Enter the matrix value = ');
M16=rot90(M15,k1)

end

end

Published with MATLAB® R2017a

You might also like