www.pudn.com > kicILC-control.rar > nonlinear_normal.asv, change:2013-04-21,size:2315b


function [sys,X0]=nonlinear_norma(t,x,u,FLAG)

% DCMOTOR 
%       S-function describing the non-linear dynamic equations of a
%       simple dcmotor given by eqs. 3.3-1, 3.3-5 and 3.3-6 of the
%       textbook "Electromechanical Motion Devices" P. Krause, McGraw
%       Hill 1989.
%
%	SYS=dcmotor(t,x,u,FLAG) returns, depending on FLAG, certain
%	system values given the current values of time, t, state 
%       vector, x, and input vector, u.
%
%	FLAG is used to indicate the value to be returned in SYS.
%       For a continuous system the following flags are used:
%
%         FLAG=0 to initialize the system 
%	  FLAG=1 to return state derivatives
%         FLAG=3 to return system outputs 
%
% Calling DCMOTOR with a FLAG of zero: [SIZES]=DCMOTOR([],[],[],0),  
%       returns a vector, SIZES, which contains the size of the state 
%       vector and other parameters (see FLAG=0) as indicated below.
%         SIZES(1) number of states
%         SIZES(2) number of discrete states
%         SIZES(3) number of outputs
%         SIZES(4) number of inputs
%         SIZES(5) number of roots (currently unsupported)
%         SIZES(6) direct feedthrough flag
%         SIZES(7) number of sample times
%
% For more information and other options see SFUNC.

% Copyright JCCK, Jan 1999

% ------------------------------------------------------------------------ %

%% Here, you must declare all the parameters of the system as global
%  of course this means that they should be loaded in the MATLAB 
%  workspace before running this S-function

% global Rf Ra Laa Lff Laf Bm Jm

if FLAG == 0,	% initialize system
  % SYS and X0
   % load system parameters
    % dcm_par;
   % This system has 3 states (x,v,i), 1 input (e), and 3 output (x,v,i)
    nx = 2; % # of states
    ny = 2; % # of outputs
    nu = 1; % # of inputs
    sys = [nx; 0; ny; nu; 0; 0];
   % Initial Conditions
    X0 = [1 0]';
elseif FLAG == 1, % states derivatives
    % Here write the State Equations.
    k01=4e3;
    k02=6.2e6;
    E1=2.5e3;
    E2=5e3;
    tref=348;
    %cBin=6;
    dx(1) = -k01*exp(-E1/tref/u)*x(1)^2;
    dx(2) = k01*exp(-E1/tref/u)*x(1)^2-k02*exp(-E2/tref/u)*x(2);
    %dx(3)=u;
    sys = dx;
elseif FLAG == 3,  % system outputs
    y(1) = x(1);
    y(2) = x(2);
    %y(3) = x(3);
    sys = y; 
else
  sys = [];
end