0% found this document useful (0 votes)
30 views3 pages

Exp 2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views3 pages

Exp 2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

SYSTEM THEORY LAB

Experiment 2: Simulation of nonlinear system dy

AIM:
Using Matlab, to simulate the dynamics of a nonlinear system (the nonlinear model
of the simple pendulum).

THEORY :

The nonlinear state equation of the simple pendulum is given by

θ̈=ω

ω̈=−g sin θ

PROCEDURE :

i. Write two MATLAB files: one, the ‘main’ script file, and the other, a function
file containing the state equation. Call the function file from the main file. For
simulation of the nonlinear state equation, use the RK-4 approximation,
implemented in MATLAB as ode45, whose syntax is given below:
[t X] = ode45(‘function name’, tspan, X0)
ii. Plot the graphs of the states X vs. time t.

MATLAB CODE :

EXPERIMENT 2 : SIMPLE PENDULUM


%%Main script

clear all, clc;

global G;

G=10;

X0=[0.1; 0]; %%Initial conditions

tspan=0:0.1:10;

This method is followed when nonlinear systems are given


[t x] = ode45('simplepend', tspan, X0); %%syntax : [t x] = ode45(fun_name, tspan, X0)

theta = x(:,1);
omega = x(:,2);

figure(1)
plot(t, theta, t, omega),
legend('\theta','\omega'),
ylabel('time'),
title('System response')
grid on

You might also like