0% found this document useful (0 votes)
111 views1 page

Solving Odes in Matlab: X X X DT DX DX, T X T X

The document describes how to solve ordinary differential equations (ODEs) using MATLAB. It provides an example of the Van der Pol equation that is solved using two M files. The example.m file specifies the initial conditions, time range, and calls the van.m file to solve the ODEs. The van.m file contains the equations defining the Van der Pol system. Executing example.m produces a time plot of the solutions x1 and x2.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
111 views1 page

Solving Odes in Matlab: X X X DT DX DX, T X T X

The document describes how to solve ordinary differential equations (ODEs) using MATLAB. It provides an example of the Van der Pol equation that is solved using two M files. The example.m file specifies the initial conditions, time range, and calls the van.m file to solve the ODEs. The van.m file contains the equations defining the Van der Pol system. Executing example.m produces a time plot of the solutions x1 and x2.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Solving ODEs in MATLAB

To solve ODEs, one can use ode solvers in the Matlab, e.g., ‘ode23tb’. You can get help
by typing ‘help ode23tb’ in the Matlab command window. As an example, consider the
following Van der Pol equation:

dx1
= x1 (1 − x 22 ) − x 2 ,
dt
dx 2
= x1 ,
dt
x1 (t = 0) =0 and x 2 (t = 0) = 0.25 .

Use the two m files attached to solve the above ODEs. Put both m files in the same
directory and execute the “example.m” file. Then you will get a time plot of x1 and x2.
Note that the “van.m” file contains information of the Van der Pol equation and the
“example.m” file specifies initial conditions, start and end integrations times and calls
“van.m” file to solve the ODEs.

1. example.m file
%%%start time
to=0;

%%%end time
tf=30;

%%%time step
step=0.5;

%%% initial conditions


xo=[0 0.25]';

%%% solve the odes


%%% t: time , x: output
[t,x]=ode23tb('van',[to:step:tf],xo);

%%% plot solutions


plot(t,x)
xlabel('time')
ylabel('value')
legend('x1','x2')

2. van.m file
function xdot=van(t,x)
xdot(1,1)=x(1)*(1-x(2)^2)-x(2);
xdot(2,1)=x(1);

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy