Netwars

prosze o pilna pomoc

[#1]
27.01.2006 13:10

wlsnie pisze zaliczenia z automatyki (w Matlabie).
Brakuje mi jednej rzeczy.
Mam regulator i potrzebuje "wsdzic" uchyb to s-funkcji

oto warunki uchybu
k=1 dla Iu(t)I >0.1
k=0.1 dla Iu(t)I =<0.1

I I <-- wartosc bezwzedna

A oto s function, gdzie to i jak w niej zapisac?

help!

function [sys,x0,str,ts] = moja(t,x,u,flag)
%CSFUNC An example M-file S-function for defining a continuous system.
% Example M-file S-function implementing continuous equations:
% x' = Ax + Bu
% y = Cx + Du
%
% See sfuntmpl.m for a general S-function template.
%
% See also SFUNTMPL.

% Copyright (c) 1990-1998 by The MathWorks, Inc. All Rights Reserved.
% $Revision: 1.5 $

A=[];

B=[];

C=[];

D=[];

switch flag,

%%%%%%%%%%%%%%%%%%
% Initialization %
%%%%%%%%%%%%%%%%%%
case 0,
[sys,x0,str,ts]=mdlInitializeSizes(A,B,C,D);

%%%%%%%%%%%%%%%
% Derivatives %
%%%%%%%%%%%%%%%
case 1,
sys=mdlDerivatives(t,x,u,A,B,C,D);

%%%%%%%%%%%
% Outputs %
%%%%%%%%%%%
case 3,
sys=mdlOutputs(t,x,u,A,B,C,D);

%%%%%%%%%%%%%%%%%%%
% Unhandled flags %
%%%%%%%%%%%%%%%%%%%
case { 2, 4, 9 },
sys = [];

%%%%%%%%%%%%%%%%%%%%
% Unexpected flags %
%%%%%%%%%%%%%%%%%%%%
otherwise
error(['Unhandled flag = ',num2str(flag)]);

end
% end csfunc

%
%=============================================================================
% mdlInitializeSizes
% Return the sizes, initial conditions, and sample times for the S-function.
%=============================================================================
%
function [sys,x0,str,ts]=mdlInitializeSizes(A,B,C,D)

sizes = simsizes;
sizes.NumContStates = 1;
sizes.NumDiscStates = 0;
sizes.NumOutputs = 1;
sizes.NumInputs = 1;
sizes.DirFeedthrough = 1;
sizes.NumSampleTimes = 1;

sys = simsizes(sizes);
x0 = zeros(1,1);
str = [];
ts = [0 0];

% end mdlInitializeSizes
%
%=============================================================================
% mdlDerivatives
% Return the derivatives for the continuous states.
%=============================================================================
%
function sys=mdlDerivatives(t,x,u,A,B,C,D)

sys = 0;

% end mdlDerivatives
%
%=============================================================================
% mdlOutputs
% Return the block outputs.
%=============================================================================
%
function sys=mdlOutputs(t,x,u,A,B,C,D)

% end mdlOutputs

[#2]
27.01.2006 14:31

up^^

btw Gdzie studiujesz i na ktorym roku?

[#3]
27.01.2006 15:37

Iformatyka stosowana III rok w Tarnowie

eot

Zaloguj się, żeby odpowiedzieć.