Simulation of a nonlinear system in MATLAB

Translate This Thread From English to

Threaded View


I have a nonlinear model that is represented by: TVo/V*X''+X'=KVo/V*D
where D is the control input. I wanted to design an integral
controller to control X to some Xd(desired) Assuming that V=Vo. I did
that with no problem. Next, I wanted to design a gain scheduling to
compensate for slowly varying V. I did that as well.

Now I have to simulate the system performance with MATLAB using both
controllers to a square wave input in which Xd varies between X1 and
X2 while slowing varying V. I'm not sure about the square input part,
I don't quite understand what and how to do it. I might be missing
something here.

If it helps I will explain how I found the design for the integral
controller:
Integral control: I did change of variables so that Y1=X, Y2=Y1'=X'
Y1'= Y2, Y2'=KD/T-Y2/T
X-Xr=e=W' (error which at steady state becomes zero b/c of the
integral controller).
D=-K1Y1-K2Y2-K3W (Assuming linear PI controller). After linearing the
system, I ended up with 2 state spaces that represent Y1-Y1ss, Y2-Y2ss
& W-Wss (where ss represents steady state).

[ Y1-Y1ss;Y2-Y2ss;W-Wss]' = [0 1 0;-K*K1/T  (-1-K*K2)/T -K*K3/T;1 0
0]* [Y1-Y1ss;Y2-Y2ss;W-Wss]

All of K,K1,K2,K3 & T have to be chosen so that the matrix is
hurwitz.

 Any explanation or help would be appreciated. Thanks.


Re: Simulation of a nonlinear system in MATLAB



crazygrey wrote:

type 'help square'?

I know there's a square wave source in simulink.  If you're not doing
this in simulink then just make a source that looks at the value of t
mod period to see where to switch.  Your system is otherwise smooth, so
you may want to run the solver right up to the switching point on your
square wave supply, then switch the input and run it up to the next
switching point -- this will save you and your solver a lot of time and
grief.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Posting from Google?  See http://cfaj.freeshell.org/google/

Do you need to implement control loops in software?
"Applied Control Theory for Embedded Systems" gives you just what it says.
See details at http://www.wescottdesign.com/actfes/actfes.html

Re: Simulation of a nonlinear system in MATLAB




''square'' generates basically a square wave with some period and duty
cycle. If I used an (ode45) solver, how do I incorporate that with the
square input? Can you elaborate on the switching point note you
mentioned?

Sorry to bother you. Thanks


Re: Simulation of a nonlinear system in MATLAB





Hmm, differential equation's solution has 2 parts. One dependent on  
initial conditions
(ode45 solution) and one dependent on excitation.

I'm not sure if I'm right but...

Matlab ode45 uses @fun which you must build. It contains your equation.
I would include excitation inside of @fun because solving ODE
is iterative procedure (Runge-Kutta and so on).
To find if it is good idea I'would try square excitation
on 1/(1+s) equation with zero initial conditions.

[y/u =1/(1+s) in Laplace operator form is dy/dt + y = u where u is square  
wave]

Otherwise I would read about convolution with impulse response.

--
Mikolaj

Re: Simulation of a nonlinear system in MATLAB



Here are my matlab test files

inertia.m    %file must have the same name as function name
--------------------------
function dy=inertia(t,y)

%excitation
u=0;              % well, line useful if you remove that one belowe
u=(sign(sin(t))>0); % if removed then no excitation is applied

%diff equation dy/dt + y = u -> s*y + y = u
% y(s+1)= u  - >  y/u = 1/(1+s)
dy=u-y;

--------------------------
main.m

% model 1/(s+1)
% ODE with excitation

[t,y]=ode45(@inertia,[0 10],[0.1]);
plot(t,y(:,1));
hold on;
plot(t,(sign(sin(t))>0),'r');    %this is my scary excitation, paste anything

% comments , you see 2 files, run the main.m. one, [0 10] is how long, 0=
.1  =

is initial cond.
% have fun

-- =


Mikolaj

Re: Simulation of a nonlinear system in MATLAB



On May 15, 5:40 pm, Mikolaj

anything

Thanks that helped


Site Timeline