MatlabTutorialODE

MatlabTutorialODE - Short Tutorial on Matlab(2003,2004 by Tomas Co Part 2 Ordinary Differential Equations 1 Suppose we want to simulate the

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Short Tutorial on Matlab (©2003,2004 by Tomas Co) Part 2. Ordinary Differential Equations 1. Suppose we want to simulate the following set of differential equations: 2 t y d d 2 3 t y d d + 2 y + 4 exp 2 - t ( ) 5 - subject to the following initial conditions, y 0 ( ) 2 t y 0 ( ) d d 1 - 2. You need to convert to state space form. Let x 1 = y and x 2 = dy/dt, then we have t x 1 d d x 2 2 t x 2 d d 2 3 - x 2 2 x 1 - 4 exp 2 - t ( ) + 5 - x 1 0 ( ) 2 x 2 0 ( ) 1 -
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
3. Next, create an m-file using either Matlab's editor or any text editor, e.g. "notepad": function dx = tutorialEqn1(t,x) % x is the state vector % to minimize parentheses you could put them % in other variables x1=x(1); x2=x(2); % write the state equations dx1 = x2; dx2 = -3*x2 -2*x1 +4*exp(-2*t) - 5; % collect the derivatives into a column vector dx = [dx1;dx2]; then save as an m-file, e.g. tutorialEqn1.m
Background image of page 2
4. In matlab, you can now invoke the ode solvers. For example, you can use
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/22/2008 for the course CS 111 taught by Professor Stuff during the Spring '08 term at Bilkent University.

Page1 / 4

MatlabTutorialODE - Short Tutorial on Matlab(2003,2004 by Tomas Co Part 2 Ordinary Differential Equations 1 Suppose we want to simulate the

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online