matlab bode图解题kg,转:Matlab中Bode图的绘制技巧

我们经常会遇到使用Matlab画伯德图的情况,可能我们我们都知道bode这个函数是用来画bode图的,这个函数是Matlab内部提供的一个函数,我们可以很方便的用它来画伯德图,但是对于初学者来说,可能用起来就没有那么方便了。

譬如我们要画出下面这个传递函数的伯德图:

1.576e010 s^2

H(s)=------------------------------------------------------------------------------------------

s^4 + 1.775e005 s^3 + 1.579e010 s^2 + 2.804e012 s + 2.494e014

(这是一个用butter函数产生的2阶的,频率范围为[20 20K]HZ的带通滤波器。)

我们可以用下面的语句:

num=[1.576e010    0       0];

den=[1 1.775e005      1.579e010      2.804e012      2.494e014];

H=tf(num,den);

bode(H)

这样,我们就可以得到以下的伯德图:

27df87df9d2c85c177c6383c.jpg

可能我们会对这个图很不满意,第一,它的横坐标是rad/s,而我们一般希望横坐标是HZ;第二,横坐标的范围让我们看起来很不爽;第三,网格没有打开(这点当然我们可以通过在后面加上grid on解决)。

下面,我们来看看如何定制我们自己的伯德图风格:

在命令窗口中输入:bodeoptions

我们可以看到以下内容:

ans =

Title: [1x1 struct]

XLabel: [1x1 struct]

YLabel: [1x1 struct]

TickLabel: [1x1 struct]

Grid: 'off'

XLim: {[1 10]}

XLimMode: {'auto'}

YLim: {[1 10]}

YLimMode: {'auto'}

IOGrouping: 'none'

InputLabels: [1x1 struct]

OutputLabels: [1x1 struct]

InputVisible: {'on'}

OutputVisible: {'on'}

FreqUnits: 'rad/sec'

FreqScale: 'log'

MagUnits: 'dB'

MagScale: 'linear'

MagVisible: 'on'

MagLowerLimMode: 'auto'

MagLowerLim: 0

PhaseUnits: 'deg'

PhaseVisible: 'on'

PhaseWrapping: 'off'

PhaseMatching: 'off'

PhaseMatchingFreq: 0

PhaseMatchingValue: 0

我们可以通过修改上面的每一项修改伯德图的风格,比如我们使用下面的语句画我们的伯德图:

P=bodeoptions;

P.Grid='on';

P.XLim={[10      40000]};

P.XLimMode={'manual'};

P.FreqUnits='HZ';

num=[1.576e010    0       0];

den=[1 1.775e005      1.579e010      2.804e012      2.494e014];

H=tf(num,den);

bode(H,P)

这时,我们将会看到以下的伯德图:

2.jpg

上面这张图相对就比较好了,它的横坐标单位是HZ,范围是[10 40K]HZ,而且打开了网格,便于我们观察-3DB处的频率值。

当然,你也可以改变bodeoptions中的其它参数,做出符合你的风格的伯德图。

附官方参数说明表

bodeoptions -Create list of Bode plot options

Syntax

P = bodeoptionsP = bodeoptions('cstprefs')

Description

P = bodeoptions returns a list of available options for Bode plots with default values set. You can use these options to customize the Bode plot appearance using the command line.

P = bodeoptions('cstprefs') initializes the plot options you selected in the Control System Toolbox Preferences Editor. For more information about the editor, see Toolbox Preferences Editor in the User's Guide documentation.

This table summarizes the Bode plot options.

OptionDescription

Title, XLabel, YLabel

Label text and style

TickLabel

Tick label style

Grid [off|on]

Show or hide the grid

XlimMode, YlimMode

Limit modes

Xlim, Ylim

Axes limits

IOGrouping [none|inputs|output|all]

Grouping of input-output pairs

InputLabels, OutputLabels

Input and output label styles

InputVisible, OutputVisible

Visibility of input and output channels

FreqUnits [Hz|rad s]

Frequency units

FreqScale [linear|log]

Frequency scale

MagUnits [dB|abs]

Magnitude units

MagScale [linear|log]

Magnitude scale

MagVisible [on|off]

Magnitude plot visibility

MagLowerLimMode [auto|manual]

Enables a lower magnitude limit

MagLowerLim

Specifies the lower magnitude limit

PhaseUnits [deg|rad]

Phase units

PhaseVisible [on|off]

Phase plot visibility

PhaseWrapping [on|off]

Enables phase wrapping

PhaseMatching [on|off]

Enables phase matching

PhaseMatchingFreq

Frequency for matching phase

PhaseMatchingValue

The value to which phase responses are matched closely

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值