Professional Documents
Culture Documents
Numerical Compitency For Mechanical Engineers Course Code: 17me2206 LAB
Numerical Compitency For Mechanical Engineers Course Code: 17me2206 LAB
Submitted by:
p.chakradhar(170070256)
TOPIC
DATE:27-12-19
DECLARATION OF MATRIX AND OPERATION DATE: 29-
12-18
SUB TOPICS:
Declaration of Matrix
CODE:
A=[16 15 14 13;12 11 10 9;8 7 6 5;4 3 2 1]
B=[1 2 2 3;22 2 2 2;3 1 2 2;4 1 1 2]
ans =
[x,y,z]=solve('x+3*y+5*z=5','4*x+y+6*z=10','2*x+7*y+z=8')
OUTPUT-
[x,y,z]=solve('x+3*y+5*z=5','4*x+y+6*z=10','2*x+7*y+z=8')
x=
219/113
y=
62/113
z=
32/113
FINDING ROOTS OF POLYNOMIAL :
CODE:
P=[5 2 1 0 1 8];
roots(P)
RESULT:-
-1.1142 + 0.0000i
-0.4413 + 1.0530i
-0.4413 - 1.0530i
0.7984 + 0.6812i
0.7984 - 0.6812i
TOPIC
INTERSECTION OF CURVES
DATE : 21-1-19
INTRODUCTION TO CONTOUR PLOT:
DATE:3-1-19
CODE:
x=-1:0.01:1;
y=x;
[X,Y]=meshgrid(x);
z1=40*sin(10*X)+40*cos(10*Y);
z2=zeros(201,201);
surfc(X,Y,z1);
hold on
surfc(X,Y,z2);
hold on
contour(X,Y,z1)
INTERSECTION OF SIN CURVES
DATE:5-1-19
CODE:
CODE:
x=-1:0.01:1;
y=x; • Output :
[X,Y]=meshgrid(x);
z1=40*sin(10*X)+40*cos(
10*Y);
z2=30*X+4*Y-60;
surfc(X,Y,z1)
hold on
surfc(X,Y,z2)
hold on;
%contour(X,Y,z1);
figure(2)
contour(X,Y,(z1))
figure(5)
contour(X,Y,(z2))
TOPIC
EIGEN VALUES
DATE : 28-1-19
EIGEN VALUES: DATE:10-
1-19
CODE:
sigma=[110 -30 0;-30 30 0;0 0 0];
eig(sigma)
sigma1=[110 -30 0;0 30 0;0 0 0];
eig(sigma1)
tau1=0.5*((eig(sigma)(2))-(eig(sigma)(3)))
tau2=0.5*((eig(sigma)(1))-(eig(sigma)(3)))
tau3=0.5*((eig(sigma)(1))-(eig(sigma)(2)))
ans =
110
30
0
TOPIC
SIMULINK
DATE : 4-2-19
SIMULINK:
DATE:24-1-19
CODE:
mass=-1;
M=1/mass;
C=1
C=1
K=100;
TOPIC
RK4 SOLVER
DATE : 25-2-19
ANS:
m =2
c =0.3000
CODE:
delta_t =1
global m k c F_o t_o t_initial =0
m=2
k=1 t_final =10
c=0.3 F_o =2
delta_t=1
t_initial=0 t_o = 3.1416
t_final=10 tspan =
F_o=2
t_o=pi
tspan=[t_initial;delta_t;t_final]
0
X_initial=[0;0]
[t,y]=ode45(Rk4_myfun,tspan,X_initial) 1
10
X_initial =
0
0
RK4 METHOD:
CODE:
global m c k
m=2;
c=0.3;
k=1;
tini=0;
tfin=10;
delta_t=1;
tspan=[tini: delta_t:tfin];
xini=[ 0.02;0 ];
[t,Y]=ode45('myfunc',tspan,xini);
figure(1);
plot(tspan,Y);
Y =
-0.0032
-0.0041
Y =
-0.0035
Y = Y=
-0.0039
0
-0.0100 Y =
0.0001 -0.0037
Y= -0.0038
-0.0051
Y =
-0.0000
-0.0100
-0.0043
Y= -0.0033
Y =
-0.0001 Y=
-0.0100
-0.0044
-0.0021 -0.0032
Y=
-0.0045 Y =
-0.0002
-0.0045
-0.0100
-0.0031
Y=
Y =
-0.0002
-0.0100 Y =
-0.0021 -0.0046
-0.0043 -0.0031
TOPIC
DATE : 11-3-19
PDE TOOL BOX: DATE:31-1-19
CODE:
% This script is written and read by pdetool and should NOT be edited.
% There are two recommended alternatives:
% 1) Export the required variables from pdetool and create a MATLAB script
% to perform operations on these.
% 2) Define the problem completely using a MATLAB script. See
% http://www.mathworks.com/help/pde/examples/index.html for examples
% of this approach.
function pdemodel
[pde_fig,ax]=pdeinit;
pdetool('appl_cb',1);
set(ax,'DataAspectRatio',[1 1 1]);
set(ax,'PlotBoxAspectRatio',[2 1 2]);
set(ax,'XLimMode','auto');
set(ax,'YLimMode','auto');
set(ax,'XTickMode','auto');
set(ax,'YTickMode','auto');
% Geometry description:
pderect([0 2 1 0],'mydomain');
set(findobj(get(pde_fig,'Children'),'Tag','PDEEval'),'String','mydomain')
% Boundary conditions:
pdetool('changemode',0)
pdesetbd(4,...
'dir',...
1,...
'1',...
'30’)
pdesetbd(3,...
'neu',...
1,...
'0',...
'0')
pdesetbd(2,...
'dir',...
1,...
'1',...
'5')
pdesetbd(1,...
'neu',...
1,...
'0',...
'0')
% Mesh generation:
setappdata(pde_fig,'Hgrad',1.3);
setappdata(pde_fig,'refinemethod','regular');
setappdata(pde_fig,'jiggle',char('on','mean',''));
setappdata(pde_fig,'MesherVersion','preR2013a');
pdetool('initmesh')
pdetool('refine')
pdetool('jiggle')
% PDE coefficients:
% PDE coefficients:
pdeseteq(1,...
'1.0',...
'2',...
'0',...
'1.0',...
'0:10',...
'0.0',...
'0.0',...
'[0 100]')
setappdata(pde_fig,'currparam',...
['1.0';...
'2 ';...
'0 ';...
'1.0'])
% Solve parameters:
setappdata(pde_fig,'solveparam',...
char('0','1008','10','pdeadworst',...
'0.5','longest','0','1E-4','','fixed','Inf'))
% Solve PDE:
pdetool('solve')
TOPIC
DATE : 18-3-19
• OPTIMISATION FUNCTION FILE
•
OPTIMISATION • function [y] = rosenbrocks(x)
TOOL BOX • y=100*(x(2)-x(1)^2)^2+(1-x(1))^2;
• end
F MINCON :
•1
GENETIC
ALGORITHM
OPTIMISATION DATE:18-3-19
CODE:
function[y]=obj(x)
y=x.^2+3*x+2;
end
TOPIC
APP DEVELOPMENT
DATE : 25-3-19
APP DEVOLOPEMENT:
CODE:
function varargout = app_dev(varargin)
% APP_DEV MATLAB code for app_dev.fig
% APP_DEV, by itself, creates a new APP_DEV or raises the existing
% singleton*.
%
% H = APP_DEV returns the handle to a new APP_DEV or the handle to
% the existing singleton*.
%
% APP_DEV('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in APP_DEV.M with the given input arguments.
%
% APP_DEV('Property','Value',...) creates a new APP_DEV or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before app_dev_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to app_dev_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Outputs from this function are returned to the command line.
function varargout = app_dev_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)