0% found this document useful (1 vote)
69 views

Lab Manual - New-NSM

This document provides a lab manual for a numerical and statistical methods course. It includes an introduction, program educational objectives, program specific outcomes, course outcomes, and experiments on numerical methods like solving equations, differential equations, and curve fitting using MATLAB.

Uploaded by

sudhir.more
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
69 views

Lab Manual - New-NSM

This document provides a lab manual for a numerical and statistical methods course. It includes an introduction, program educational objectives, program specific outcomes, course outcomes, and experiments on numerical methods like solving equations, differential equations, and curve fitting using MATLAB.

Uploaded by

sudhir.more
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

Artificial Intelligence and Machine Learning TE-Mechanical-2019

“Techno-Social Excellence”
Marathwada Mitra Mandal’s
Institute of Technology, Lohgaon, Pune - 411 047

Department of Mechanical Engineering

Lab Manual

Subject: Numerical and Statistical Method


(2019 Course) 302041

Prepared by,
Prof. Sudhir S. More

Page 1
Artificial Intelligence and Machine Learning TE-Mechanical-2019

Page 2
Artificial Intelligence and Machine Learning TE-Mechanical-2019

Page 3
Artificial Intelligence and Machine Learning TE-Mechanical-2019

Department of Mechanical Engineering


PEO’s & PSO’s

A. Program Educational Objectives: (PEO`s)

Statement:

1. To apply knowledge of Mechanical Engineering to analyze and find viable


solutions to technical problems in allied fields
2. Design and develop engineering system components
3. To help employability through entrepreneurship
4. Enhance professional career to meet needs of society

B. Program Specific Outcomes : ( PSO`s)

Statement:

1. Students will be able to apply the knowledge of Mechanical Design,


Thermal and Manufacturing Processes to meet the needs of Industry
2. Students will be able to implement aids of CAD/CAM/CAE and
programming tools for the interdisciplinary industry needs.

Page 4
Artificial Intelligence and Machine Learning TE-Mechanical-2019

Course Outcomes:

CO CO. No. CO Statement

CO 1 302041.pr.1 Solve the Roots of Equations by using numerical method in MATLAB software

CO 2 302041.pr.2 Solve the Differential equation by using numerical method in MATLAB software

CO 3 302041.pr.3 Solve the integration by using numerical method in MATLAB software

Use in MATLAB software and numerical method to fit the suitable curve for given
CO 4 302041.pr.4 set of data

Use MATLAB/Minitab software for regression analysis (least square ) of given


CO 5 302041.pr.5 dataset

CO 6 302041.pr.6 Determine statistical measures of given set of data using software’s like Minitab

Analyse the mechanical engineering application dataset and find the solution by
CO 7 302041.pr.7 appropriate numerical method by using programming knowledge for

CO PO Mapping:

CO. No. PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PSO1 PSO2
302041.pr.1 PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PSO1 PSO2

302041.pr.2 3 2 2 2

302041.pr.3 3 2 2 2

302041.pr.4 3 2 2 2

302041.pr.5 3 2 2 2

302041.pr.6 3 2 2 2

302041.pr.7 3 2 2 2 2

Average

Page 5
Artificial Intelligence and Machine Learning TE-Mechanical-2019

INDEX
Exp. Page
Title of Experiment
No. No

01 Programs of Roots of equation using suitable programming language 7

Programs of Ordinary differential equation using suitable programming


02
language
Programs of Numerical Integration using suitable programming language
03

Program of Curve fitting using least square technique using suitable


04
programing

05 Program of Regression analysis using suitable programing

06 Determine statistical measures using suitable programing

One program based mini project using mechanical engineering application


07
dataset

Page 6
Artificial Intelligence and Machine Learning TE-Mechanical-2019

EXPERIMENT NO. 1

Title: Programs of Roots of equation using suitable programming language

Programs
% Matlab program for Newton-Raphson method
% when accuracy is given
clc;
clear;
f = inline('exp(x)*cos(x)-1.2');
df = inline('exp(x)*(cos(x)-sin(x))');
ddf = inline('-2*exp(x)*sin(x)');
x1=input('\n Enter the value of initial guess x1: ');
acc=input('\n Enter the given value of accuracy: ');
f(x1);
df(x1);
ddf(x1);
while(abs(f(x1)*ddf(x1))<0)
fprintf('\n Enter value of x1 again: ');
f(x1);
d(x1);
ddf(x1);
end
x2=x1-(f(x1)/df(x1));
while(abs(x1-x2)>acc)
x1=x2;
f(x1);
df(x1);
x2=x1-(f(x1)/df(x1));
end
fprintf('\n The root of given equation is =%f',x2);

Page 7
Artificial Intelligence and Machine Learning TE-Mechanical-2019

% Matlab program for Newton-Raphson method


% when no. of iterations is given
clc;
f = inline('x^3-3*x-5');
df = inline('3*x^2-3');
ddf = inline('6*x');
x1=input('\n Enter the value of initial guess x1: ');
n=input('\n Enter the total no. of iterations: ');
f(x1);
df(x1);
ddf(x1);
while(abs(f(x1)*ddf(x1))<0)
fprintf('\n Enter value of x1 again: ');
f(x1);
df(x1);
ddf(x1);
end
x2=x1-(f(x1)/df(x1));
for i=1:1:n
x1=x2;
f(x1);
df(x1);
x2=x1-(f(x1)/df(x1));
end
fprintf('\n The root of given equation is =%f',x2);

Page 8
Artificial Intelligence and Machine Learning TE-Mechanical-2019

Solver
% X = FZERO(FUN,X0) tries to find a zero of the function FUN near X0
% X = FZERO(FUN,X0), where X0 is a scalar value, uses X0 as a starting guess.
% FZERO looks for an interval containing a sign change for FUN and containing X0..

Example No.1
X=fzero(inline('exp(x)*cos(x)-1.4'),0);
X
Example No.2
To use the default tolerance and to display iteration information.

X = fzero(inline('exp(x)*cos(x)-1.4'),0,optimset('disp','iter'));
X

Page 9
Artificial Intelligence and Machine Learning TE-Mechanical-2019

EXPERIMENT NO. 2

Title: Programs of ordinary differential equation using suitable programming language

Program
% Matlab Program for Euler's Method
clc;
f=inline('((x-y^2))');
x0=input('\n Enter the given value of x0=');
y0=input('\n Enter the given value of y0=');
h=input('\n Enter the given value of step size h=');
xn=input('\n Enter the given value of xn at which yn is to be calculated=');
n=(xn-x0)/h;
fprintf('\n The total no. of steps are=%d',n);
% Assumption
x(1)=x0;
y(1)=y0;
% Loop to calculate Approximate solution using Euler formula
fprintf('\n\t X \t\t\ty ');
for i=1:1:n
x(i+1)=x0+i*h;
y(i+1)=y(i)+h*f(x(i),y(i));
fprintf('\n%f \t%f \t%f',x(i+1),y(i+1));
end

Output

Enter the given value of x0=0

Enter the given value of y0=1

Enter the given value of step size h=1

Enter the given value of xn at which yn is to be calculated=4

Page 10
Artificial Intelligence and Machine Learning TE-Mechanical-2019

The total no. of steps are=4

X y

1.000000 0.000000

2.000000 1.000000

3.000000 2.000000

4.000000 1.000000 >>

% Matlab Program for Modified Euler's Method


clc;
f=inline('(sqrt(x+y))');
x0=input('\n Enter the given value of x0=');
y0=input('\n Enter the given value of y0=');
h=input('\n Enter the given value of step size h=');
acc=input('\n Enter accuracy=');
xn=input('\n Enter the given value of xn at which yn is to be calculated=');
n=(xn-x0)/h;
fprintf('\n The total no. of steps are=%d',n);
% Assumption
x(1)=x0;
y(1)=y0;
% Loop to calculate approximate solution using modified Euler formula
fprintf('\n\t X \t\t\tY ');
for i=1:1:n+1
x(i+1)=x0+i*h;
yp=y(i)+h*f(x(i),y(i));
yc=y(i)+((h/2)*(f(x(i),y(i))+f(x(i+1),yp)));
while(abs(yc-yp)>acc)
yp=yc;

Page 11
Artificial Intelligence and Machine Learning TE-Mechanical-2019

yc=y(i)+((h/2)*(f(x(i),y(i))+f(x(i+1),yp)));
end
y(i+1)=yc;
fprintf('\n%f \t%f \t%f',x(i+1),y(i+1));
end

Output

Enter the given value of x0=0

Enter the given value of y0=0.36

Enter the given value of step size h=0.1

Enter accuracy=0.001

Enter the given value of xn at which yn is to be calculated=0.2

The total no. of steps are=2


X Y
0.100000 0.426265
0.200000 0.504499
0.300000 0.593732 >>

%Matlab Program for Runge Kutta Second Order Method


clc;
f=inline('(-(y+x*y^2))');
x0=input('\n Enter the given value of x0=');
y0=input('\n Enter the given value of y0=');
h=input('\n Enter the given value of step size h=');
xn=input('\n Enter the given value of xn at which yn is to be calculated=');
n=(xn-x0)/h;

Page 12
Artificial Intelligence and Machine Learning TE-Mechanical-2019

fprintf('\n The total no. of steps are=%d',n);


% Assumption
x(1)=x0;
y(1)=y0;
% Loop to calculate Approximate solution using RK-2 method
fprintf('\n\t X \t\t\tY ');
for i=1:1:n
x(i+1)=x0+i*h;
m1=h*f(x(i),y(i));
m2=h*f(x(i)+h,y(i)+m1);
y(i+1)=y(i)+((1/2)*(m1+m2));
fprintf('\n%f \t%f \t%f',x(i+1),y(i+1));
end

Output

Enter the given value of x0=0

Enter the given value of y0=1

Enter the given value of step size h=0.1

Enter the given value of xn at which yn is to be calculated=0.3

The total no. of steps are=3.000000e+000


X Y
0.100000 0.900950
0.200000 0.805263 >>

Page 13
Artificial Intelligence and Machine Learning TE-Mechanical-2019

%Matlab Program for Runge Kutta Fourth Order Method


clc;
f=inline('(sqrt((x^2)+y))');
x0=input('\n Enter the given value of x0=');
y0=input('\n Enter the given value of y0=');
h=input('\n Enter the given value of step size h=');
xn=input('\n Enter the given value of xn at which yn is to be calculated=');
n=(xn-x0)/h;
fprintf('\n The total no. of steps are=%d',n);
% Assumption
x(1)=x0;
y(1)=y0;
% Loop to calculate Approximate solution using RK-4 method
fprintf('\n\t X \t\t\tY ');
for i=1:1:n
x(i+1)=x0+i*h;
m1=h*f(x(i),y(i));
m2=h*f(x(i)+(h/2),y(i)+((m1)/2));
m3=h*f(x(i)+(h/2),y(i)+((m2)/2));
m4=h*f(x(i)+h,y(i)+(m3));
y(i+1)=y(i)+((1/6)*(m1+2*m2+2*m3+m4));
fprintf('\n%f \t%f \t%f',x(i+1),y(i+1));
end

Output

Enter the given value of x0=0

Enter the given value of y0=1

Enter the given value of step size h=0.2

Page 14
Artificial Intelligence and Machine Learning TE-Mechanical-2019

Enter the given value of xn at which yn is to be calculated=0.4

The total no. of steps are=2


X Y
0.200000 1.211264
0.400000 1.449537 >>

Solver
Matlab Syntax to solve first order ODE
% ODE45 Solve non-stiff differential equations, medium order method.
% [Xe, Ye] = ODE45 (ODEFUN, XSPAN, Y0) with XSPAN = [X0: h: XFINAL]
% above syntax integrates the system of differential equations y' = f (x, y) from time X0 to %
XFINAL with initial condition Y0 at each step size h.
Example
clc;
f=inline('(y-x)/(y+x)');
x0=0;
xn=0.1;
y0=1;
h=0.01;
xspan=[x0:h:xn];
[xe,ye]=ode45(f,xspan,y0);
[xe,ye]
plot(xe,ye(:,1),'b*-');

Matlab Syntax to solve second order ODE

Firstly, Create separate F.m file to define given second order ODE as follows in new file
%function dy=F(x,y);
%dy=[y(2);(2*x*y(2))-(4*y(1))+4];
Where
% dy/dx=y(1)=phi=inline('z')

Page 15
Artificial Intelligence and Machine Learning TE-Mechanical-2019

% dz/dx=y(2)=f=inline('2xz-4y+4')
% Then, solve diff. equation using ode45 as follows
clc;
type F
x0=0;
y0=1;
z0=-2;
xn=0.4;
h=0.1;
xspan=[x0:h:xn];
[xe,ye]=ode45('F',xspan,[y0;z0]);
[xe,ye]
plot(ye);
xlabel('x');
ylabel('solution y');
title('Solution of second order ODE')
legend('Blue:y(1)=dy/dx','Green:y(2)=dz/dx');

Example2
Firstly, Create separate F.m file to define given second order ODE as follows in new file
function dy=F(x,y)
dy=[y(2);x*(y(2)^2)-y(1)^2];
%dy/dx=y(1)=phi=inline('z');
%dz/dx=y(2)=f=inline('(x(z^2))-y^2');
Then, solve diff. equation using ode45 as follows in command window
type F
x0=0;
y0=1;
z0=0;
xn=0.2;
h=0.2;
xspan=[x0:h:xn];
Page 16
Artificial Intelligence and Machine Learning TE-Mechanical-2019

[xe,ye]=ode45('F',xspan,[y0;z0]);
[xe,ye]
plot(ye);
xlabel('x');
ylabel('solution y');
title('Solution of second order ODE')
legend('Blue:y(1)=dy/dx','Green:y(2)=dz/dx');

Page 17
Artificial Intelligence and Machine Learning TE-Mechanical-2019

EXPERIMENT NO. 3

Title: Programs of Numerical Integration using suitable programming language

Program for trapezoidal Rule

Function y= f(x)
Y=x^3+2x-1

X0=input (‘enter the initial limit x0 :’);


Xn=input (‘enter the initial limit xn:’);
N= input (‘enter the number of steps :’);
H= (xn-x0)/2;
ans=0;
For i=1: n-1
ans=ans+ (f(x0+i*h)); % find the values of y1,y2
,y3,……………….yn-1
end %ans=0+f(0+1*0.5) wh
ere x0=0,h=0.5)
ans=2*ans; % 2(y1+y2+y3………yn-1)
ans1=f(x0) +f (xn);
area=ans+ans1;
area=area*(h/2)
fprintf(‘Total area =%f,area’);

Page 18
Artificial Intelligence and Machine Learning TE-Mechanical-2019

Program for Simpson rule

Function y= f(x)
Y=x^3+2x-1
X0=input (‘enter the initial limit x0 :’);
Xn=input (‘enter the initial limit xn:’);
n= input (‘enter the valueof n :’);
While (mod (n, 2)=0)
n=(‘input the value of n again:’)
end
h=(xn-x0/2);
ans=0;
for i=1:n-1
if (mod(I,2)=0)
ans=ans=4*(f(x0+i*));
else
ans=ans+2*(f(x0+i*h));
end
end
ans1=f(x0)+f(xn);
area=ans+ans1
area=area*(h/3);
fprintf(‘/n total area =%f,area);

Solvers Single integration


Matlab Syntax to find solution of single definite numerical integral-quadl
% (Quadl=adaptive Lobatto quadrature which evaluates integral numerically)
% (Q = quadl('function',A,B) tries to approximate the integral of function from A to B)
Q = quadl('1./(x.^3-2*x-5)',0,2);
Q
%

Page 19
Artificial Intelligence and Machine Learning TE-Mechanical-2019

OR
F = inline('1./(x.^3-2*x-5)');
Q = quadl(F,0,2);

Double Integeration
% DBLQUAD Numerically evaluates double integral.
% DBLQUAD (F, Xmin, Xmax, Ymin, Ymax) evaluates the double integral F(X, Y)
% F(X, Y) should accept a vector X and a scalar Y and return a vector of values of integrand.
Example No.1
Q = dblquad(inline('y*sin(x)+x*cos(y)'), pi, 2*pi, 0, pi);
Q
Example No.2
Q=dblquad(inline('sqrt(max(1-(x.^2+y.^2),0))'),-1,1,-1,1);
Q
Example No.3
Q=dblquad(inline('exp(x+y)'),0,1,0,1);

Page 20
Artificial Intelligence and Machine Learning TE-Mechanical-2019

EXPERIMENT NO. 4

Title: Program of Curve fitting using least square technique using suitable programing

Linear equation
% Matlab Program to fit straight line/First degree curve (y=ax+b)
clc;
clear;
n=input('\nEnter the value of data entries n= ');
for i=1:1:n
x(i)=input('Enter the values of x= ');
y(i)=input('Enter the values of y= ');
end
sx=0;
sy=0;
sxx=0;
sxy=0;
for i=1:1:n
sx=sx+x(i);
sy=sy+y(i);
sxx=sxx+x(i)*x(i);
sxy=sxy+x(i)*y(i);
end
delta=sxx*n-sx*sx;
delta1=sxy*n-sy*sx;
delta2=sxx*sy-sx*sxy;
a=delta1/delta;
b=delta2/delta;
fprintf('\nThe values of constants a=%f and b=%3f',a,b);
fprintf('\nThe equation of straight line is y=%2.5f x + %2.5f',a,b);
% Plotting best fit curve y=ax+b using points (x, ya) and observed curve using (x, y)
for i=1:1:n
Page 21
Artificial Intelligence and Machine Learning TE-Mechanical-2019

ya(i)=a*x(i)+b; %To find the calculated ya using eq. ya=ax+b as per solution
end
hold on
plot(x,y,'b*-');
plot(x,ya,'r+-');
xlabel('X');
ylabel('Y');
title('Graph of first degree curve using least square criteria');

% Matlab Program to fit power equation ab^x


clc;
n=input('\nEnter the value no of data entries,n= ');
for i=1:1:n
x(i)=input('Enter the values of x= ');
y(i)=input('Enter the values of y= ');
Y(i)=log10(y(i));
X(i)=x(i);
end
sx=0;
sy=0;
sxx=0;
sxy=0;
for i=1:1:n
sx=sx+X(i);
sy=sy+Y(i);
sxx=sxx+X(i)*X(i);
sxy=sxy+X(i)*Y(i);
end
delta=sxx*n-sx*sx;
delta1=sxy*n-sy*sx;
delta2=sxx*sy-sx*sxy;
a1=delta1/delta;
Page 22
Artificial Intelligence and Machine Learning TE-Mechanical-2019

b1=delta2/delta;
a=10^a1;
b=10^b1;
fprintf('\nThe values of constants a1=%f and b1=%f',a1,b1);
fprintf('\nThe values of constants a=%f and b=%f',a,b);
fprintf('\nThe power equation is y=%2.4f * %2.4f ^x',a,b);
% Plotting best fit curve y=ab^x using points (x, ya) and observed curve using (x, y)
for i=1:1:n
ya(i)=a*power(b,x(i)); %To find the calculated ya using equation ya=ab^x
end
hold on
plot(x,y,'b*-')
plot(x,ya,'r*--')
xlabel('X');
ylabel('Y');
title('Graph of power function y=ab^x curve using least square criteria');

Matlab Program to fit an exponential curve a*e^bx


clc;
n=input('\nEnter the value no. of data entries n= ');
for i=1:1:n
x(i)=input('Enter the values of x= ');
y(i)=input('Enter the values of y= ');
Y(i)=log(y(i));
X(i)=x(i);
end
sx=0;
sy=0;
sxx=0;
sxy=0;
for i=1:1:n

Page 23
Artificial Intelligence and Machine Learning TE-Mechanical-2019

sx=sx+X(i);
sy=sy+Y(i);
sxx=sxx+X(i)*X(i);
sxy=sxy+X(i)*Y(i);
end
delta=sxx*n-sx*sx;
delta1=sxy*n-sy*sx;
delta2=sxx*sy-sx*sxy;
a1=delta1/delta;
b1=delta2/delta;
a=exp(b1);
b=a1;
fprintf('\n The values of constants a1=%f and b1=%f',a1,b1);
fprintf('\n The values of constants a=%f and b=%f',a,b);
fprintf('\n The equation of exponential curve is y=%2.4fe^%2.4fx',a,b);
% Plotting best fit curve y=ae^bx using points (x, ya) and observed curve using (x, y)
for i=1:1:n
ya(i)=a*exp(b*x(i)); %To find the calculated ya using equation ya=aebx
end
hold on
plot(x,y,'b*-')
plot(x,ya,'r*--')
xlabel('X');
ylabel('Y');
title('Graph of exponential curve using least square criteria');

Page 24
Artificial Intelligence and Machine Learning TE-Mechanical-2019

Solvers for Numerical Methods for curve fitting

Curve fitting

1. For linear equation, y=ax+b


x = [10 20 30 40 50 60 70 80];
y = [25 70 380 550 610 1220 830 1450];
constants = polyfit(x,y,1)
constants =
19.4702 -234.2857
Slope and intercept

2. For quadratic equations y=ax2+bx+c


x = [10 20 30 40 50 60 70 80];
y = [25 70 380 550 610 1220 830 1450];
constants = polyfit(x,y,2)
constants =
0.0372 16.1220 -178.4821
i.e values of a,b,and c

3. Fit for y=axb


fSSR.m (function file)
function f = fSSR(a,xm,ym)
yp = a(1)*xm.^a(2);
f = sum((ym-yp).^2);
end
output
x = [10 20 30 40 50 60 70 80];
y = [25 70 380 550 610 1220 830 1450];
fminsearch(@fSSR, [1, 1], [], x, y)
ans =
2.5384 1.4359
Page 25
Artificial Intelligence and Machine Learning TE-Mechanical-2019

4. Fit for y=abx


fSSR2.m (function file)
function f = fSSR2(a,xm,ym)
yp = a(1)*a(2).^xm;
f = sum((ym-yp).^2);
end
output
x = [10 20 30 40 50 60 70 80];
y = [25 70 380 550 610 1220 830 1450];
fminsearch(@fSSR2, [1, 1], [], x, y)
ans =
150.5740 1.0287

5. Fit for y=aebx


fSSR3.m (function file)
function f = fSSR3(a,xm,ym)
yp = a(1)*exp(a(2)*xm);
f = sum((ym-yp).^2);
end
output
x = [10 20 30 40 50 60 70 80];
y = [25 70 380 550 610 1220 830 1450];
fminsearch(@fSSR3, [1, 1], [], x, y)
ans =
150.5741 0.0283

Page 26
Artificial Intelligence and Machine Learning TE-Mechanical-2019

EXPERIMENT NO. 5

Title: Program of Regression analysis using suitable programing

Quadratic Equation
% Matlab Program to fit second degree curve/parabola/Quadratic Equation (y=ax^2+bx+c)
clc;
clear;
n=input('\nEnter the value no. of data entries n= ');
for i=1:1:n
x(i)=input('Enter the values of x= ');
y(i)=input('Enter the values of y= ');
end
sx=0;
sy=0;
sxx=0;
sxxx=0;
sxxxx=0;
sxy=0;
sxxy=0;
for i=1:1:n
sx=sx+x(i);
sy=sy+y(i);
sxx=sxx+x(i)*x(i);
sxxx=sxxx+x(i)*x(i)*x(i);
sxxxx=sxxxx+x(i)*x(i)*x(i)*x(i);
sxy=sxy+x(i)*y(i);
sxxy=sxxy+x(i)*x(i)*y(i);
end
delta=sxxxx*(sxx*n-sx*sx)-sxxx*(sxxx*n-sxx*sx)+sxx*(sxxx*sx-sxx*sxx);
delta1=sxxy*(sxx*n-sx*sx)-sxxx*(sxy*n-sy*sx)+sxx*(sxy*sx-sy*sxx);
delta2=sxxxx*(sxy*n-sy*sx)-sxxy*(sxxx*n-sxx*sx)+sxx*(sxxx*sy-sxx*sxy);
Page 27
Artificial Intelligence and Machine Learning TE-Mechanical-2019

delta3=sxxxx*(sxx*sy-sx*sxy)-sxxx*(sxxx*sy-sxx*sxy)+sxxy*(sxxx*sx-sxx*sxx);
a=delta1/delta;
b=delta2/delta;
c=delta3/delta;
fprintf('\nThe values of constants a=%f ,b=%f and c=%f',a,b,c);
fprintf('\nThe equation of second degree curve is y=%2.3f x^2 + %2.3f x + %2.3f',a,b,c);
% Plotting best fit curve y=ax^2+bx+c using points (x, ya) and observed curve using (x, y)
for i=1:1:n
ya(i)=a*x(i)*x(i)+b*x(i)+c; %To find the calculated ya using equation ya=ax^2+bx+c
end
hold on
plot(x,y,'b*-');
plot(x,ya,'r+-');
xlabel('X');
ylabel('Y');
title('Graph of second degree curve using least square criteria');

Page 28
Artificial Intelligence and Machine Learning TE-Mechanical-2019

EXPERIMENT NO. 6

Title: Determine statistical measures using suitable programing

Descriptive Statistical By Using Minitab


Summarize the data
Data

Order Priority Order Quantity Sales Ship Mode Shipping Cost


Low 26 390.2 Express Air 7.4
High 38 259.7175 Regular Air 5.03
Not Specified 18 71.22 Regular Air 0.7
Critical 1 192.49 Delivery Truck 30
Medium 25 767.26 Regular Air 4
Critical 48 207.08 Regular Air 5.17
Low 23 683.68 Regular Air 8.99
Low 33 10168.23 Express Air 19.99
High 20 269.66 Regular Air 4.59
Medium 20 10281.79 Regular Air 24.49
Low 2 65.31 Regular Air 12.98

Descriptive statistics summarize and describe the prominent features of data. Use Display
Descriptive Statistics to determine how many book orders were delivered on time, how many
were late, and how many were initially back ordered for each shipping center.
Display descriptive statistics
1. Open the data set, Shipping Data.MTW.
2. Choose Stat > Basic Statistics > Display Descriptive Statistics.
3. In Variables, enter Shipping Cost.
4. In By variables (optional), enter Center Status

Page 29
Artificial Intelligence and Machine Learning TE-Mechanical-2019

5. Click Statistics.
6. Uncheck First quartile, Median, Third quartile, N nonmissing, and N missing
7. Check N total.

8. Click OK in each dialog box.


Results are displayed as follows

Variab N N Mean SE StDe Mini Q1 Medi Q3 Maxi Skew Kurt


le * Mean v mum an mum ness osis
Shippi 839 0 12.83 0.188 17.26 0.490 3.300 6.070 13.99 164.7 2.55 7.75
ng 9 9 4 0 3
Cost

Page 30
Artificial Intelligence and Machine Learning TE-Mechanical-2019

n 8399 8399 8399


mean 25.57173473 1775.878179 12.83855697
max 50 89061.05 164.73
min 1 2.24 0.49
range 49 89058.81 164.24
sd 14.48020902 3584.837097 17.26302419

Some charts for analysis

Page 31
Artificial Intelligence and Machine Learning TE-Mechanical-2019

Page 32
Artificial Intelligence and Machine Learning TE-Mechanical-2019

EXPERIMENT NO. 7

Title: One program based mini project using mechanical engineering application dataset

Objective: - Students should develop a online calculator for a mechanical system using
programmable language

Page 33

You might also like