书中的错误纠正与记录

  最近在看Feedback Control of Dynamic Systems 8th edition (Gene F. Franklin, J. David Powell etc.) (z-lib.org).pdf书时,书中273页的代码有一处错误:

正确如下:

1 k=1;
2 s=tf('s');
3 w=logspace(-2,2);
4 sysH=1/(s+k);
5 [mag,phase]=bode(sysH,w);
6 figure
7 loglog(w,squeeze(mag));
8 figure
9 semilogx(w,squeeze(phase));

图像如下:

 使用subplot命令后,并设置图片属性后:

代码:

1 k=1;
2 s=tf('s');
3 w=logspace(-2,2);
4 sysH=1/(s+k);
5 [mag,phase]=bode(sysH,w);
6 subplot(211)
7 loglog(w,squeeze(mag));
8 subplot(212)
9 semilogx(w,squeeze(phase));

通过图片编辑完成后,在图片上右击选定显示代码,加上图片属性代码:

function createsubplot(Parent1, X1, Y1)
%CREATESUBPLOT(Parent1, X1, Y1)
%  PARENT1:  subplot parent
%  X1:  semilogx x 数据的向量
%  Y1:  semilogx y 数据的向量

%  由 MATLAB 于 12-Mar-2024 11:15:26 自动生成

% 创建 subplot
subplot1 = subplot(2,1,2,'Parent',Parent1);
hold(subplot1,'on');

% 创建 semilogx
semilogx(X1,Y1,'Parent',subplot1);

box(subplot1,'on');
hold(subplot1,'off');
% 设置其余坐标区属性
set(subplot1,'ContextMenu','XGrid','on','XMinorTick','on','XScale','log','YGrid','on',...
    'YMinorGrid','on');

形成的图片如下:

 



posted @ 2024-03-12 11:10  叕叒双又  阅读(3)  评论(0编辑  收藏  举报