NAST LAB EXPERIMENTS, (PRANAY), (ME), (3rd SEM), (MVSIT), (00255111119)
NAST LAB EXPERIMENTS, (PRANAY), (ME), (3rd SEM), (MVSIT), (00255111119)
NAST LAB EXPERIMENTS, (PRANAY), (ME), (3rd SEM), (MVSIT), (00255111119)
TECHNOLOGY
ETME - 253
SUBMITTED TO :
B tech , (MVSIT)
ROLL No : - 00155111119
Experiment – 1
Aim – To find the addition of two matrices.
Output –
Experiment – 2
Aim – To find the multiplication of two matrices
clc
clear all
format compact
A=input('Enter the matrix A');
[m1,n1]=size(A);
B=input('Enter the matrix B');
[m2,n2]=size(B);
fprintf('\n Multiplication of matrix\n');
if(n1==m2)
D = A*B
else
disp('for these matrices multiplication is not possible')
end
Output –
Experiment – 3
Output –
Experiment – 4
clc
clear all
n=input('enter the number of variables');
a=input('enter the augumented matrix A/b-');
for j=1:n
for i=1:n
if(i~=j)
t=a(i,j)/a(j,j);
for k=1:n+1
a(i,k)=a(i,k)-a(j,k).*t;
end
end
end
end
fprintf('\nThe diagonal matrix is:-\n')
disp(a)
fprintf('\nThe solution is:-\n')
for i=1:n
fprintf('x[%d]=%f\n',i,a(i,n+1)./a(i,i));
end
Output –
Experiment – 6
Output –
Experiment – 7
Output
–
Experiment-8
clc
clear all
format compact
syms x
y = input('Enter the function to be integrated');
xO= input('Enter xO:');
xn= input('Enter xn:\');
n=input('Enter the number of subintervals:');
h=(xn-xO)/n
s= subs(y,xn0= subs(y,xO)+y*subs(y,xO+h0;
for i=3:2:n-1
s=s+4*subs(y,xO+i*h0)+2* subs(y,xO+(i-1)*h);
end
t=vpa((h/3)*s,7);
fprintf('The value of the integral is=%f \n');
disp(t);
Experiment-9
clc
clear all
format compact
format short g
syms x y
f = input('Enter the function :');
x0 = input('Enter x0:');
y0 = input('Enter y0:');
h = input('Enter the value of h:');
r = input('Enter the value of x:');
while (r>x0)
y0 = y0+h*subs(f,{x,y},{x0,y0});
x0 = x0+h
disp(x0);
disp(y0);
end
Experiment-10
Aim: To find the solution of ordinary differential equation using runge Kutta
method.
clc
clear all
format compact
format rat
format short g
syms x y
f=input('Enter the function :');
x0=input('Enter x0:');
y0=input('Enter y0:');
h=input('Enter the value of h:');
xn=input('Enter the value of xn:');
while(x0~=xn)
if(x0==xn)
break
end
k1=vpa(h*subs(f,{x,y},{x0,y0}),5)
k2=vpa(h*subs(f,{x,y},{x0+h/2,y0+k1/2}),5)
k3=vpa(h*subs(f,{x,y},{x0+h/2,y0+k2/2}),5)
k4=vpa(h*subs(f,{x,y},{x0+h,y0+k3}),5)
k=vpa((k1+(k2+k3)*2+k4)/6,5)
x0=x0+h;
y0=vpa(y0+k,6);
fprintf('when x=%g\n');
disp(x0);
fprintf('the value of f=%3.3f');
disp(y0);
end
Experiment – 11
clc
clear all
fprintf('\n unit step function\n')
a=input('enter the value of a:')
t=(a-5):0.00001:(a+5);
n=size(t);
for(i=1:n(2))
if t(i)<a
r(i)=0;
else
r(i)=1;
end
i=i+1;
end
plot(t,r)
axis([a-5,a+5,0,5])
title('unit step function');
xlabel('X axis');
ylabel('Y axis');
Output –
Graph –