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

📄 pmodel.m

📁 书籍代码:遗传演算法原理与应用_活用MATLAB(Source Code)
💻 M
字号:
function dy=pmodel(t,y)
%PMODEL Differential equation system for inverted pendulum.
%	
%	PMODEL(T,Y)
%	  T - Time.
%	  Y - Current state of inverted pendulum.
%	Returns derivatives of the pendulum state.
%	
%	The state vector Y has three values:
%	  Y(1) - Pendulum angle from -2 pi to 2 pi radians.
%	  Y(2) - Pendulum angular velocity in radians/second.
%	  Y(3) - Force being applied to the pendulum.
%	
%	NOTES: Angle is 0 radians when the pendulum points up.
%	       Force stays constant, its derivative is always 0.
%	
%	See also APPCS1, PLINEAR.

% Mark Beale, 12-15-93
% Copyright 1992-2000 The MathWorks, Inc.
% $Revision: 1.8 $  $Date: 2000/06/15 04:15:15 $

if nargin < 2, error('Not enough input vectors.'); end

% STATE
angle = y(1);
vel   = y(2);
force = y(3);

% CALCULATE DERIVATIVES
dangle = vel;
dvel   = 9.81*sin(angle) - 2*vel + force;
dforce = zeros(size(force));

% RETURN DERIVATIVES
dy = [dangle; dvel; dforce];

⌨️ 快捷键说明

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