⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 neurofuz.m

📁 FISMAT accommodates different arithmetic operators, fuzzification and defuzzification algorithm, imp
💻 M
字号:
function  [sys, x0] = neurofuz(t,x,u,flag,ctr,Tsamp)% NEUROFUZ An S-function for discrete controllers with a sample time.% % As opposed to the s-functions FUZZY11, FUZZY21 NEUROFUZ does not pass previous% values of inputs and outputs through the X parameter. Another increase in speed% is possible by creating a MEX-file. (See Release Notes to SIMULINK)%% The number of inputs to the NEUROFUZ block can be a vector of any size. This% is possible with the SIMULINK version 1.3.%% This s-function is nearly identical to the demo template SFUNDSC2.M in the % /TOOLBOX/SIMULINK/BLOCKS directory of SIMULINK 1.3% Only two parameters are added in the function head (ctr,Tsamp). % CTR = name of the controller m-file% Tsamp = sampling time% CTR and Tsamp are passed as function parameters in the S-function block menu% as function parameters. See examples with FUZZY11 and FUZZ21 for more infor-% mation.% A simulink "testfile" for the s-function blocks is ctest1_s.m the corresponding% controller file is ct1_c1.m.%% FSTB - Fuzzy Systems Toolbox for MATLAB% Copyright (c) 1993-1996 by Olaf Wolkenhauer% Control Systems Centre at UMIST% Manchester M60 1QD, UK%%       23-November-1994	if abs(flag) == 2,  % The FLAG==2 branch is at the top of the file for efficiency, since  % the S-function will be called with FLAG==2 very frequently.  % If FLAG==2, then SIMULINK is looking for the next point in real time.   if abs(round(t/Tsamp)-(t/Tsamp)) < 1e+8*eps,    sys = feval(ctr,u,x,Tsamp);  else    % (SYS =) XNEW = X    sys = x;  end;elseif flag == 3,  % If FLAG==3, then SIMULINK wants to know what the next output is.  % **** In this template system, y gets the current state x ****  % (SYS =) Y = X  sys = x;elseif flag == 4,  % If FLAG==4, then SIMULINK wants to know what TNEXT is.  % TNEXT is the time when the integrator should be constrained to  % call the system with FLAG==2.  % First compute the number of samples so far  numSamp = floor(t/Tsamp + 1e+8*eps);  % Now sys returns TNEXT, the next time the discrete state should  % be updated.  % (SYS =) TNEXT = ...  sys = (numSamp + 1)*Tsamp;  elseif flag  == 0,  % This part takes care of all initialization; it is used only once.  % The sizes vector is six elements long, and it looks like this:  % sizes(1) = number of continuous states  sizes(1) = 0;  % sizes(2) = number of discrete states  sizes(2) = 1;  % sizes(3) = number of system outputs (length of output y)  sizes(3) = 1;  % sizes(4) = number of system inputs (length of input u)  sizes(4) = -1;  % sizes(5) = number of discontinuous roots; unused feature, set to zero  sizes(5) = 0;  % sizes(6) = direct feedthrough flag; used to detect algebraic loops.  % Set sizes(6) to 1 if the output y depends directly on the input u.  % Otherwise, it should be set to 0.  sizes(6) = 0;  % Set the initial conditions on the states  x0 = 0;  % (SYS =) SIZES = [0 1 1 1 0 0]';  sys = sizes';else   % Flags not considered here are treated as unimportant.  % Notice that since there are no continuous states in this system,  % there is no need to deal with FLAG==1.  % Output is set to [].  sys = [];end     % if abs(flag) == ...

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -