simlinq2.m

来自「matlab 遗传算法工具箱 对学习遗传算法很有帮助 别再有重复的」· M 代码 · 共 33 行

M
33
字号
% SIMLINQ2.M      (Model of Linear Quadratic Problem, s-function)
%
% This function implements the model of the Linear Quadratic Problem.
%
% Syntax:  [sys, x0] = simlinq2(t, x, u, flag)
%
% Input parameters:
%    t         - given time point
%    x         - current state vector
%    u         - input vector
%    flag      - flags
%
% Output parameters:
%    sys       - Vector containing the new state derivatives
%    x0        - initial value            
%
% Author:     Hartmut Pohlheim
% History:    23.03.94     file created

function [sys, x0] = simlinq2(t, x, u, flag);

% Linear Systems Description

   if abs(flag) == 1
   	sys(1) = u(1) + x(1);       % Derivatives
   elseif abs(flag) == 0
   	sys=[1,0,0,1,0,0]; x0 = [100];
   else
   	sys = [];		% Real time update (ignored).
   end


% End of function

⌨️ 快捷键说明

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