Cleveland State University

Department of Electrical and Computer Engineering

 

EEC 510

Linear Systems

 

function Ex01a(ControlMag)

 

% function Ex01a.

% Nonlinear system simulation.

% This is the same as Ex01 except with more matrix usage.

% To see the effects of linearization, run this with

% ControlMag values = 0.05, 0.5, and 5.

 

% Close all open figures.

close all;

 

% The simulation runs from 0 to tf in steps of dt.

dt = 0.02;

tf = 5;

 

% Nonlinear simulation.

x = [1; 1];

xarray = [];

for t = 0 : dt : tf

  u = ControlMag * sin(2*pi*t);

  xdot = [-1 / x(2) / x(2); u * x(1)];

  x = x + dt * xdot;

  xarray = [xarray x];

end

 

% Linearized simulation.

xbar = [0; 0];

xarrayLin = [];

for t = 0 : dt : tf

  u = ControlMag * sin(2*pi*t);

  xbardot = [2 * xbar(2); (1 - t) * u];

  xbar = xbar + dt * xbardot;

  x0 = [1 - t; 1];

  xarrayLin = [xarrayLin x0 + xbar];

end

 

% Compare the results of the nonlinear and linearized simulations.

figure;

t = [0 : dt : tf];

plot(t, xarray(1, :), '-', t, xarrayLin(1, :), '--');

title(['x1, Control Magnitude = ',num2str(ControlMag), ...

   ', Solid = Nonlinear, Dashed = Linearized']);

figure;

plot(t, xarray(2, :), '-', t, xarrayLin(2, :), '--');

title(['x2, Control Magnitude = ',num2str(ControlMag), ...

   ', Solid = Nonlinear, Dashed = Linearized']);

 


Professor Simon's Home Page

Department of Electrical and Computer Engineering

Cleveland State University


Last Revised: March 13, 2001