Integral Lab
Integral Lab
ID: 221538
Assingnment-01
b)
clc
clear all
close all
Transpose
m=input('enter the number of rows for matrix A:\n')
n=input('enter the number of columns for matrix A:\n')
A=input('enter the matrix A:\n');
B=zeros(m,n);
[m,n]=size(A);
[n,m]=size(B);
for i=1:m
for j=1:n
B(j,i)=A(i,j);
end
end
disp('transpose of A is:')
disp(B)
c)
clc
clear all
close all
m=input('enter the number of rows for matrix A:\n')
n=input('enter the number of columns for matrix A:\n')
A=input('enter the matrix A:\n');
n2=input('enter the number of rows of B matrix:\n')
m2=input('enter the number of columns of B matrix:\n')
B=input('enter the matrix B:\n')
if m==n2 & n==m2
X=(1/2*(A)+B)
disp('the addition of given two matrices is:')
disp(X)
else
disp('addition is not possible')
[p,q]=size(x);
Y=zeros(p,q);
for i=1:p
for j=1:q
Y(j,i)=X(i,j);
end
end
disp('transpose of Y is:')
disp(Y)
end
d) clc
clear all
close all
m=input('Enter the number of rows for matrix A:\n');
n=input('Enter the number of columns for matrix A:\n');
A=input('Enter the elements of matrix A:\n');
C=zeros(m,n);
[m,n]=size(A);
for i=1:m
for j=1:n
C(i,j)=A(j,i);
end
end
X=0.5*(A+C);
Y=0.5*(A-C);
A_reconstructed=X+Y;
disp('Original matrix A:')
disp(A)
disp('Symmetric matrix X:')
disp(X)
disp('Skew-symmetric matrix Y:')
disp(Y)
e)
clc;
close all
m=input('Enter the number of rows for matrix C:\n');
n=input('Enter the number of columns for matrix C:\n');
C=input('Enter the elements of matrix C:\n')
[m,n]=size(C);
isHermitian=true;
for i=1:m
for j=1:n
if C(i,j)~=conj(C(j,i))
isHermitian=false;
break;
end
end
if~isHermitian
break
end
end
if isHermitian
disp('The matrix is Hermitian')
else
disp('The matrix is not Hermitian')
end
a)
clc
clear all
close all
Ans to the Question no-02
n1=input('enter the number of rows of A matrix:\n')
m1=input('enter the number of columns of A matrix:\n')
A=input('enter the matrix A:\n')
n2=input('enter the number of rows of B matrix:\n')
m2=input('enter the number of columns of B matrix:\n')
B=input('enter the matrix B:\n')
if m1==n2
disp('the multiplication of given two matrices is:')
else
disp(' multiplication is not possible')
end
b)
clc
clear all
close all
n1=input('enter the number of rows of A matrix:\n')
m1=input('enter the number of columns of A matrix:\n')
A=input('enter the matrix A:\n')
n2=input('enter the number of rows of B matrix:\n')
m2=input('enter the number of columns of B matrix:\n')
B=input('enter the matrix B:\n')
if m1==n2
C=A*B
disp('the multiplication of given two matrices is:')
disp(C)
else
disp(' multiplication is not possible')
end
c)
clc
clear all
close all
n1=input('enter the number of rows of A matrix:\n')
m1=input('enter the number of columns of A matrix:\n')
A=input('enter the matrix A:\n')
n2=input('enter the number of rows of B matrix:\n')
m2=input('enter the number of columns of B matrix:\n')
B=input('enter the matrix B:\n')
if m1==n2
C=A*B
disp('the multiplication of given two matrices is:')
disp(C)
else
disp(' multiplication is not possible')
end
if m2==n1
disp('the multiplication of given two matrices is:')
D=B*A
disp(D)
else
disp(' multiplication is not possible')
end
if C==D
disp('AB=BA')
elseif C~=D
disp('AB not equal BA')
end
clc;
clear all;
close all;
x=linspace(-pi ,pi,190);
y=x.*sin(1./x);
plot(x,y,'r ')
xlabel('x');
ylabel('y');
axis('equal'),grid
title('the graph of xsin(1/x)')
clc;
clear all;
close all;
x=linspace(-pi ,pi,190);
y=sinh(x);
plot(x,y,'r ')
xlabel('x');
ylabel('y');
axis('equal'),grid
title('the graph of sinh(x)')
clc;
clear all;
close all;
theta=linspace(0,12*pi,1000);
r= theta;
polarplot(theta,r,'k');
clc;
clear all;
close all;
constant=linspace(0,2*pi,2000);
r= constant;
polarplot(constant,r)
title('the graph of r= constant ')
xlabel('x')
ylabel('y')
axis('equal')
grid on
clc,
clear all;
close all;
x=linspace(-10,10,100)
y=abs(x+7)+abs(x-9)
plot(x,y,'--')
xlabel('x')
ylabel('y')
axis('equal'),grid
10. Sketch
clc,
clear all;
close all;
t=linspace(-pi,pi,100)
y=exp(-0.4*t).*(sin(t))
plot(t,y,'r')
xlabel('x')
ylabel('y')
axis('equal'),grid
clc;
clear all;
close all
t=linspace(0,pi,100);
y=cos(t);
plot(t,y,'--');
xlabel('x');
ylabel('y');
axis('equal'),grid
hold on
x=linspace(-100,100,100)
z=1-(x.*x/2)+(x.*x/24);
plot(x,z,'--');
hold off
t=linspace(0,6*pi,100)
x=cos(t)
y=sin(t)
z=t
subplot(2,2,1),plot3(x,y,z)
subplot(2,2,2),plot3(x,y,z),view(0,90)
subplot(2,2,3),plot3(x,y,z),view(0,0)
subplot(2,2,4),plot3(x,y,z),view(90,0)
clc;
clear all;
close all;
x=linspace(-pi,pi,2000)
y=x.^2.*sin(1./x)
plot(x,y,'r')
title('the graph of x^2*sin(1/x)');
xlabel('x')
ylabel('y')
axis('equal'),
grid on;
Assingnment-02
a) Volume of integration.
clc;
clear ll;
close all;
syms x y f(x,y)
% considering z=f(x,y);
f(x,y)=3.*x.^3+3*x.^2.*y;
n=input('increment:\n');
sum_f=0;
for i=1:n:3
for j=0:n:2
sum_f=sum_f + double(f(i,j));
end
end
small_area=n.^2;
volume=sum_f*small_area;
disp('the required volume is ');
disp(volume)
b) Surface revolution.
clc;
clear all;
close all;
x=linspace(0,1,1000);
y=x.^3
dx=x(2)-x(1)
surface_area=0
for i=1:length(x)
r= y(i)
dA=2*pi*r*dx
surface_area= surface_area+dA
end
disp(['The surface area is ',num2str(surface_area)])
clc;
clear all;
close all;
F1=inline('1-6.*x.^2.*y')
I1=dblquad(F1,0,2,-1,1)
F2=inline('x.^2*y')
I2= dblquad(F2,-1,2,0,1)