Exp 2
Exp 2
AIM:
Using Matlab, to simulate the dynamics of a nonlinear system (the nonlinear model
of the simple pendulum).
THEORY :
θ̈=ω
ω̈=−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 :
global G;
G=10;
tspan=0:0.1:10;
theta = x(:,1);
omega = x(:,2);
figure(1)
plot(t, theta, t, omega),
legend('\theta','\omega'),
ylabel('time'),
title('System response')
grid on