You are on page 1of 1

%%%%Home Assigment#01: Matrix calculator%%%%

clc
clear all
disp('Warning:This Matrix calculator will only work as per Matrix rules');
disp('For Addition and Subtraction Order should be same');
disp('For Multiplication Columns of 1st matrix = Rows of 2nd Matrix');

m1=input('Number of rows for matrix 1= ');


n1=input('Number of columns for matrix 1= ');
for i=1:m1
for f=1:n1
a(i,f)=input(['value of Matrix 1(',num2str(i),',',num2str(f),') =']);
end
end
disp(a)

m2=input('Number of rows for matrix 2= ');


n2=input('Number of columns for matrix 2= ');
for k=1:m2
for j=1:n2
b(k,j)=input(['value of Matrix 2(',num2str(k),',',num2str(j),') =']);
end
end
disp(b);
disp('Please press 1 for sum, press 2 for subtraction, press 3 for
multiplication, press 4 for division')
s=input('Enter press relevant number for Operation =');
if s==1
res=a+b;
elseif s==2
res=a-b;
elseif s==3
res=a*b;
elseif s==4
res=a/b;
else
disp('Please Try Again with relevant selection');
end
disp(res);

You might also like