%%%%%%%%%%%%%%%%%%%%%% one_blk.m %%%%%%%%%%%%%%%%%%%%
% Feedback Control Problems with MATLAB
% and the Control System Toolbox
% D. K. Frederick and J. H. Chow, May 1999
% last revision: 6/15/99 HS
%----------------------------------------------------
clear,clf
activity = -1; % force activity menu to appear
while (activity < 1) | (activity > 3),
disp(' 1 <= Enter or modify a 1-block model')
disp(' 2 <= Calculations')
disp(' 3 <= Plots')
activity = input('Select action, or enter 0 to quit....');
if activity == 0, disp('Completed single-block analysis'), return, end
if activity == 1, % enter block model in either tf or zp form
model_form = -1; % force model entry menu to appear
while (model_form < 1) | (model_form > 6),
disp(' 1 <= Build LTI object from TF data')
disp(' 2 <= Build LTI object from ZPK data')
disp(' 3 <= Display numerator and denominator values')
disp(' 4 <= Display ZPK values')
disp(' 5 <= Create unity-feedback closed-loop model')
disp(' 6 <= Activate keyboard')
model_form = input...
('Select model form or enter 0 for top-level menu.....');
if (model_form == 0 | isempty(model_form)),
activity = -1; % return to activity menu
break % terminate "while model_form..." loop
end % of " if model_form == 0"
%+++++++++++++++++++ enter model in TF form ++++++++++++++++++++
if model_form == 1,
disp(' ')
disp(' **** Interactive entry of transfer function using TF data ****')
disp(' ')
% remove any stale zeros, poles, & gain from workspace
clear zer zer_str zer_last pol pol_str pol_last gain gain_str gain_last
disp('Enter coefficients of numerator and denominator polynomials.')
disp('Have initialized with values from Example 2.3')
%-----------------------------------------------------
num_last = [3 2]; % numerator specified in Example 2.3
den_last = [2 4 5 1]; % denominator specified in Example 2.3
num_str = vec2str(num_last); % string representation of numerator
den_str = vec2str(den_last); % string representation of denominator
cmd = 'n'; % 'n' ==> model is not OK
while cmd == 'n',
disp(' ')
% allow user to enter new values for H(s)
num = input(['Enter numerator "' num_str '"....']);
if isempty(num), num = num_last; end % CR ==> use old value
den = input(['Enter denominator "' den_str '"....']);
if isempty(den), den = den_last; end % CR ==> use old value
num_str = vec2str(num); %
den_str = vec2str(den);
disp('Numerator and denominator polynomials of tf form are:')
eval(['num = ' num_str]);
eval(['den = ' den_str]);
cmd = input('Model OK? (y|n)','s');
num_last = num; % save previous values in case want to reuse
den_last = den;
H = tf(num,den);
end % of "while" for "run another case"
disp('Model has been entered as TF object')
model_form = -1; % force model_form menu to reappear
end % of "if model_form ==1"
%++++++++++++++++ enter model in ZP form +++++++++++++++++++++
if model_form ==2,
disp(' ')
disp(' **** Interactive entry of transfer function using ZPK data ****')
disp(' ')
disp('Enter H(s) in terms of zeros, poles, and gain ')
disp('Have initialized with values from Example 3.1')
% remove any stale numerator & denominator from workspace
clear num num_str num_last pol pol_str pol_last
zer_last = [-2; -1.5]; % 2 real zeros
pol_last = [-0.5; -0.2+0.6*i; -0.2-0.6*i; -8]; % 4 poles, 2 complex
gain_last = 2; % gain
zer_str = vec2str(zer_last) % string repr of numerator with ';'
pol_str = vec2str(pol_last) % string repr of denominator with ';'
gain_str = num2str(gain_last) % string repr of gain
cmd = 'n'; % 'n' ==> model not OK
while cmd == 'n',
disp(' ')
% allow user to enter new values for H(s)
zer = input(['Enter zeros as column vector "' zer_str '"....']);
if isempty(zer), zer = zer_last; end % CR ==> use old value
pol = input(['Enter poles as column vector "' pol_str '"....']);
if isempty(pol), pol = pol_last; end % CR ==> use old value
gain = input(['Enter gain "' gain_str '"....']);
if isempty(gain), gain = gain_last; end % CR ==> use old value
zer_str = vec2str(zer) %
pol_str = vec2str(pol)
gain_str = num2str(gain)
disp('Zeros, poles, & gain of zp form are:')
eval(['zer = ' zer_str]);
eval(['pol = ' pol_str]);
eval(['gain = ' gain_str]);
cmd = input('Model OK? (y|n)','s');
zer_last = zer; % save previous values in case want to reuse
pol_last = pol;
gain_last = gain;
H = zpk(zer,pol,gain);
end % of "while cmd = n"
disp('Model has been entered in zero-pole-gain form')
model_form = -1; % force model_form menu to reappear
end % of "if model_form == 2"
%++++++++++ Display ZPK values ++++++++++++++
if model_form == 4,
if (exist('H')),
disp('Zeros, poles, and gain of H(s) are:')
[zer,pol,gain] = zpkdata(H,'v')
disp('********>');pause
else
disp...
('Need model defined as LTI object')
disp('*******>');pause
end % of "if exist..."
model_form = -1; % force model_form menu to reappear
end % of "model_form == 4"
%+++++++++++ Display numerator and denominator values ++++++++++++++
if model_form == 3,
if (exist('H')),
disp('Numerator and denominator of H(s) are:')
[num,den] = tfdata(H,'v')
disp('********>');pause
else
disp('Need model defined as LTI object')
disp('*******>');pause
end
model_form = -1; % force model_form menu to reappear
end % of "model_form == 3"
%+++++++++++++++ unity feedback closed-loop system +++++++
if model_form == 5,
if (exist('H')),
disp('saving open-loop model as "HOL" ')
disp('....because new closed-loop system will be "H"')
disp('Numerator and denominator of closed-loop system are:')
HOL = H;
H = feedback(HOL,1)
disp('*******>');pause
else
disp(' ')
disp('require open-loop model')
disp('******>');pause
end
model_form = -1; % force model_form menu to reappear
end % of "model_form == 5"
%+++++++++++++++++ activate keyboard ++++++++++++++++++++
if model_form == 6 ,
disp('keyboard is active to allow:')
disp(' * examining workspace')
disp(' * entry of externally-defined model')
disp(' * use of any Matlab commands')
disp('To resume, enter "return"')
keyboard
model_form = -1; % return to model_form menu
end % of "model_form == 6"
%-------
end % of " while model_form....."
end % of " if activity == 1"
%========== end of model creation ===========
%=========== calculations ===============
if activity == 2,
disp('Select calculations to be done for model')
calc_type = -1; % force calculation type menu to appear
while (calc_type < 1) | (calc_type > 6),
disp(' 1 <= Numerator & denominator of H(s)')
disp(' 2 <= Zeros, poles, and gain of H(s)')
disp(' 3 <= Residues and poles of H(s)')
disp(' 4 <= Display state-space matrix')
disp(' 5 <= Damping ratio & natural freq of poles of H(s)')
disp(' 6 <= examine work space')
calc_type = input...
('Select type of calculation or enter 0 for top-level menu.....');
%+++++++++++++++++ no more calculations ++++++++++++++++++++
if (calc_type == 0 | isempty(calc_type)),
disp('Completed calculations')
activity = -1; % return to activity menu
break % terminate "while calc_type...." loop
end % of "calc_type == 0"
%++++++++++++++++++++ calculate num & den ++++++++++++++
if calc_type == 1,
if (exist('H')),
disp('Numerator and denominator of H(s) are:')
[num_calc,den_calc] = tfdata(H,'v')
disp('********>');pause
else
disp('Need model as LTI object for this calculation')
disp('*******>');pause
end
calc_type = -1; % force calc_type menu to reappear
end % of "calc_type == 1"
%++++++++++++++++++++ calculate zeros, poles, and gain ++++++++
if calc_type == 2,
if (exist('H')),
disp('Zeros,
没有合适的资源?快使用搜索试试~ 我知道了~
《反馈控制问题:使用MATLAB及控制系统工具箱》中的所有源程序
共281个文件
m:275个
mat:6个
5星 · 超过95%的资源 需积分: 9 44 下载量 113 浏览量
2010-12-13
18:44:42
上传
评论 2
收藏 232KB ZIP 举报
温馨提示
反馈控制问题 那本书中的所有.m文件程序 在brook/cole网站上找到的
资源推荐
资源详情
资源评论
收起资源包目录
《反馈控制问题:使用MATLAB及控制系统工具箱》中的所有源程序 (281个子文件)
ONE_BLK.M 15KB
ch2ex.m 13KB
ep10_1.m 11KB
ch3ex.m 8KB
ch10ex.m 7KB
SAT.M 7KB
ch4ex.m 6KB
FLEX.M 6KB
ch6ex.m 6KB
RIGID.M 5KB
ch5ex.m 5KB
ex9_4.m 5KB
ch7ex.m 5KB
cp9_2.m 4KB
ex9_2.m 4KB
cp10_2.m 4KB
ex9_5.m 4KB
cp8_3b.m 4KB
wif8_3b.m 4KB
ex8_3.m 4KB
ep10_2.m 4KB
ex9_1.m 4KB
cp8_3a.m 4KB
wif8_3c.m 4KB
wif3_5.m 3KB
cp10_3.m 3KB
cp10_4.m 3KB
ex9_3.m 3KB
cp4_2.m 3KB
ex8_2.m 3KB
cp8_2.m 3KB
cp7_1.m 3KB
ex8_1.m 3KB
wif8_3a.m 3KB
cp9_1a.m 3KB
wif6_1.m 3KB
cp9_1b.m 3KB
cp7_3.m 2KB
wif10_6.m 2KB
p7_6.m 2KB
p6_6.m 2KB
cp4_4.m 2KB
cp7_2c.m 2KB
cp5_4b.m 2KB
cp3_3b.m 2KB
p7_7.m 2KB
POWERXD.M 2KB
cp4_3.m 2KB
epow.m 2KB
cp7_2a.m 2KB
cp6_2.m 2KB
cp3_3a.m 2KB
p10_13.m 2KB
wif5_2.m 2KB
p10_14.m 2KB
fig9_11.m 2KB
cp3_4.m 2KB
cp10_1.m 2KB
p10_12.m 2KB
cp7_2b.m 2KB
wif6_2c.m 2KB
wif6_2b.m 2KB
cp5_2c.m 2KB
fig9_14.m 2KB
p6_13.m 2KB
cp3_2b.m 2KB
wif7_3.m 2KB
cp8_1.m 2KB
cp6_1.m 2KB
wif5_1.m 2KB
wif6_2a.m 2KB
wif8_3d.m 2KB
p10_10.m 2KB
cp3_5a.m 2KB
cp5_4c.m 2KB
p10_9.m 2KB
p6_12.m 2KB
p10_11.m 2KB
wif8_2a.m 2KB
p6_14.m 2KB
wif10_5.m 2KB
fig9_6.m 2KB
cp4_1.m 2KB
cp5_2a.m 2KB
cp2_1.m 2KB
p6_9.m 2KB
p6_11.m 2KB
fig9_10.m 2KB
cp9_1c.m 2KB
fig9_8.m 2KB
p6_10.m 2KB
p7_5.m 2KB
cp3_5c.m 2KB
fig10_4a.m 2KB
p7_2.m 2KB
p7_4.m 2KB
fig7_5.m 2KB
fig8_8.m 2KB
cp6_4.m 2KB
fig8_7b.m 2KB
共 281 条
- 1
- 2
- 3
资源评论
- 四枫院夜一2015-01-23不错,和原书是对应的,可以找书对着看
- xiaoduoli2014-11-29在看 反馈控制问题-使用matlab及其控制系统工具箱 这本书,下载代码来学学
- liuchunqiang222012-12-19在看 反馈控制问题-使用matlab及其控制系统工具箱 这本书,下载代码来学学。谢谢哦
- chenpeng33612014-09-02经典 经典 经典
zhengkaiyuan
- 粉丝: 2
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功