BFC12 X Mqjy 8 HPMLBK KRDSizs VX DVPD UCFAHkf 2 Q GN 5 Y

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

The ode45 solver is a medium-order solver.

The solver syntax is:


[t,y]=ode45(ydot,tspan,y0)
Where:
ydot is the name of the function file that evaluates
the right side of a differential equation of the form
dy/dt=f(t,y)
tspan is a row vector containing the starting and
ending values of t
y0 is a vector on initial conditions
Lecture 7- Log Decrement

MEEM 3700

The equations for ode45 must be in State-variable form.


Consider the second order equation:
3&x& + 8 x& + 100 x = 0

In state variable form, we define the variables:


z1 = x

z 2 = x&

the equation can then be written in state-variable form as:


1
z&1 = z 2
z&2 = (8 z 2 + 100 z1 )
3

The Initial Conditions become:


z1 (0) = x(0) = 5

Lecture 7- Log Decrement

z 2 (0) = x& (0) = 15

MEEM 3700

The ode function file that computes the values of z&1 and z&2
and stores them in a column vector might look like:
function f=example(t,z)
x=z(1);
xd=z(2);
xdd=-1/3*(8*xd+100*x)
f=[xd;xdd];
Note

f(1) represents z&1


f(2) represents z&2

Lecture 7- Log Decrement

MEEM 3700

The MATLAB code that call ode45 to solve the


equation is:
time interval
initial conditions
[t,x]=ode45(example,[0,3],[5;15])

the name of the function being called

Lecture 7- Log Decrement

MEEM 3700

A dressed-up program might include:


% DOE Solver for a single degree of freedom system in free vibration
clear all
clc
%Enter system parameters
global m c k
m=3;c=8;k=100;
%Enter initial conditions
x0=5;v0=15;
ic=[x0;v0];
%Enter time span for solution
tspan=[0 3];
%Call solver
[t,x]=ode45('shapsdof',tspan,ic);
%Set up plot
plot(t,x(:,1)),xlabel('Time (sec)'),ylabel('Displacement (inches)'),title('System
Response')
Lecture 7- Log Decrement

MEEM 3700

10

function f=shapsdof(t,z)
global m c k
x=z(1);
xd=z(2);
f=zeros(2,1);
xdd=[-(c/m)*xd-(k/m)*x];
f=[xd;xdd];

Lecture 7- Log Decrement

MEEM 3700

11

MEEM 3700
Mechanical Vibrations
Shapton
Mechanical Engineering-Engineering Mechanics
Michigan Technological University
Copyright 2007

Lecture 7- Simulink

MEEM 3700

Start Simulink from MATLAB by typing simulink


The simulink browser will appear and contains the blocks
needed to model basic systems.
There are two major classes of elements: blocks and lines
Blocks are used to generate, modify, combine, output and
display signals
Lines are used to transmit signals
lines transmit in the direction of the arrow
Lines can tap off of other lines
Lines can not inject a signal into another line
Lecture 7- Simulink

MEEM 3700

Building a model involves a series of steps:


Begin by clicking on the New Model button
The necessary blocks are gathered from the Library
Browser and placed in the model window
The parameters of the blocks are modified to correspond
with the system being modeled
The blocks are connected with lines to complete the
model

Lecture 7- Simulink

MEEM 3700

1. Click on the + in front of a library to


display the blocks available for use
2. Click on a block to display a shory
description of its function
3. Drag desired blocks to the workspace
and position in the desired order

Double click on a block to open a window to set its parameters


To flip a block, right click the block; Format; Flip; Flip Block
Lecture 7- Simulink

MEEM 3700

Draw lines to connect the blocks


Drag the mouse from where the line starts (output
terminal of a block) to where it ends (input terminal
of another block)
To branch a signal to 2 or more terminals, click on
the connecting line and add the branch to the
additional terminal
(To quickly connect blocks and to insure a good
connection, select the source block, then hold down the
Ctl key while left clicking on the destination block)
Lecture 7- Simulink

MEEM 3700

To run the simulation, go to the simulation menu and


click Start.

(See section 3.10 of the text for a more complete


introduction to simulink and for examples illustrating
its use)

Lecture 7- Simulink

MEEM 3700

1
s

1
s

Integrator

Integrator1

1
Gai n2

Scope

8
Gai n
1
Gai n1

For convenience, we need to flip the blocks in the


feedback loop so that the input terminal is on the
right and the output terminal is on the left before
drawing in the connecting lines.

Lecture 7- Simulink

MEEM 3700

Original block orientation


1
s

1
s

Integrator

Integrator1

1
Gai n2

Scope

8
Gai n
1
Gai n1

Gain blocks flipped


1
Gain2

1
s

1
s

Integrator

Integrator1

Scope

8
Gain
1
Gain1

Lecture 7- Simulink

MEEM 3700

&x&

-1/3
-K-

x&

1
s

Gain2

1
s

Integrator

Integrator1

x
Scope

8 x&

Gain

-K-

100 x

Gain1

100

6
5

Displacemenl - inches

4
3
2
1
0
-1
-2
-3

Lecture 7- Simulink

0.5

1.5
t - sec

MEEM 3700

2.5

You might also like