资源简介
这是一个系统建模的实例,是基于小球平衡的,用matlab做的界面以及写的相关程序
代码片段和文件信息
function ballbeam(action)
% BALLBEAM demonsrates Proportional-Derivative (PD) control as applied to a
% ball and beam demonstration experiment. Execute by calling with no arguments.
%
% P and PD controllers are implemented which manipulates the beam angle in
% response to the position of the ball on the beam. The setpoint is indicated
% by the red marker and is adjusted using the slider at the bottom of the figure.
% The control gain Kc and the Derivative Time constant Td are adjusted by
% a sliders located in the right hand control panel.
%
% This demo has been tested on Matlab 5.3 and Matlab 6.0. Some of the user
% interface code was shamelessly ripped out of the standard Matlab demos.
%
% Jeff Kantor
% Version 1.0
% March 24 2001
if nargin < 1
action = ‘initialize‘;
end
persistent ballradius beamlength beamwidth
persistent xmin xmax umin umax g dt
persistent t x v u done
persistent Kc Td N xsp xlast dterm Ad Bd
persistent ballHndl xball yball
persistent beamHndl xbeam ybeam
persistent markerHndl xmarker ymarker
persistent setpointHndl
persistent runHndl resetHndl stopHndl closeHndl infoHndl
persistent gainHndl gaintxtHndl gainlblHndl
persistent dervHndl dervtxtHndl dervlblHndl
persistent manualHndl modeHndl mode
persistent bbAxes plotAxes plotHndl legHndl tdata xdata xspdata
switch lower(action)
case {‘initialize‘}
% Basic dimensions.
ballradius = 1;
beamlength = 20;
beamwidth = 0.3;
% System parameters
xmin = 0; % Left limit
xmax = beamlength; % Right limit
umin = -0.25; % Minimum beam angle
umax = 0.25; % Maximum beam angle
g = 0.05; % Gravitational Constant
dt = 0.2; % Time Step
% Set initial conditions for ball and beam position
t = 0; % Initial time
x = beamlength/2; % Initial Ball position
v = 0; % Initial Velocity
u = 0; % Initial beam angle
done = 0; % Done Flag
% Setup controller with initial parameters
mode = 1; % Flag start in manual mode
% Mode == 1 => Manual
% Mode == 2 => Proportional
% Mode == 3 => PD
Kc = 0.1; % Proportional Gain
Td = 20; % Derivative time constant
N = 10; % Maximum derivative gain
xsp = x; % Initial setpoint
xlast = x; % Last measured value
dterm = 0; % Derivative term
Ad = Td/(Td+N*dt); % Derivative filter constant
Bd = Kc*Td*N/(Td+N*dt); % Derivative gain
% Create figure
figNumber = figure( ...
‘Name‘‘Ball & Beam Demo‘ ...
‘NumberTit
- 上一篇:canny边缘检测算法的matlab实现
- 下一篇:MATLAB QR分解
相关资源
- 全面详解LTE MATLAB建模、仿真与实现
- 全面详解LTE:MATLAB建模、仿真与实现
- 《全面详解LTE:MATLAB建模、仿真与实
- 《全面详解LTE:MATLAB建模、仿真与实
- BLDC matlab建模
- PV组件的MATLAB建模
- MATLAB建模与仿真应用教程(第2版 )
- 全面详解LTE:MATLAB建模、仿真与实现
- 应用matlab建模与仿真
- 《全面详解LTE MATLAB建模、仿真与实现
- 全面详解LTE:MATLAB建模、仿真与实现
- 基于MATLAB的QPSK建模仿真(小论文+m源
- 电扫阵列MATLAB建模与仿真[A·D·布朗
- 全面详解LTE:MATLAB建模、仿真与实现
- 全面详解LTE:MATLAB建模、仿真与实现
- 全面详解LTE MATLAB建模、仿真与实现
- 全面详解LTE:MATLAB建模、仿真与实现
- 带整流负载同步发电机的Matlab建模和
- 基于Matlab的六自由度搬运机器人建模
- matlab粒子群算法辨识传递函数模型包
- 电池管理系统matlab建模代码
- 永磁直驱风力发电系统的MATLAB建模
- 锁相环 PLL matlab建模
- 太阳能光伏发电系统MATLAB建模
- OFDM系统原理及Matlab建模仿真
- 飞机系统matlab建模
- 全面详解LTE:MATLAB建模、仿真与实现
- 平衡车MATLAB建模
- lssvm matlab建模技术
- matlab建模代码
评论
共有 条评论