1.如何在matlab里提取bode数据?
2.求 matlab 中bode源代码
3.matlab中phase与angle的区别
4.matlab画幅角图的方法?
5.Matlab中信号经FFT后的相位谱表达式p1=mod(phase(y)*180/pi,360)是什么意思,求详细解释
如何在matlab里提取bode数据?
在matlab 提取bode图数据如下:1丶我们现在matlab里面编写好自己要绘制图形的代码。
2丶在代码后面加上[mag,phase,w] = bode(sys);
3丶这时候我们在workplace界面就可以看到我们需要的数据了。
这样就解决了在matlab 提取bode图数据的问题。
求 matlab 中bode源代码
function [magout,phase,w] = bode(a,b,c,d,iu,w)
%BODE Bode frequency response of LTI models.
%
% BODE(SYS) draws the Bode plot of the LTI model SYS (created with
% either TF, ZPK, SS, or FRD). The frequency range and number of
% points are chosen automatically.
%
% BODE(SYS,{ WMIN,WMAX}) draws the Bode plot for frequencies
% between WMIN and WMAX (in radians/second).
%
% BODE(SYS,W) uses the user-supplied vector W of frequencies, in
% radian/second, at which the Bode response is to be evaluated.
% See LOGSPACE to generate logarithmically spaced frequency vectors.
%
% BODE(SYS1,SYS2,...,W) graphs the Bode response of multiple LTI
% models SYS1,SYS2,... on a single plot. The frequency vector W
% is optional. You can specify a color, line style, and marker
% for each model, as in
% bode(sys1,'r',sys2,'y--',sys3,'gx').
%
% [MAG,PHASE] = BODE(SYS,W) and [MAG,PHASE,W] = BODE(SYS) return the
% response magnitudes and phases in degrees (along with the frequency
% vector W if unspecified). No plot is drawn on the screen.
% If SYS has NY outputs and NU inputs, MAG and PHASE are arrays of
% size [NY NU LENGTH(W)] where MAG(:,:,k) and PHASE(:,:,k) determine
% the response at the frequency W(k). To get the magnitudes in dB,
% type MAGDB = *log(MAG).
%
% For discrete-time models with sample time Ts, BODE uses the
% transformation Z = exp(j*W*Ts) to map the unit circle to the
% real frequency axis. The frequency response is only plotted
% for frequencies smaller than the Nyquist frequency pi/Ts, and
% the default value 1 (second) is assumed when Ts is unspecified.
%
% See also BODEMAG, NICHOLS, NYQUIST, SIGMA, FREQRESP, LTIVIEW, LTIMODELS.
% Old help
%warning(['This calling syntax for ' mfilename ' will not be supported in the future.'])
%BODE Bode frequency response for continuous-time linear systems.
% BODE(A,B,C,D,IU) produces a Bode plot from the single input IU to
% all the outputs of the continuous state-space system (A,B,C,D).
% IU is an index into the inputs of the system and specifies which
% input to use for the Bode response. The frequency range and
% number of points are chosen automatically.
%
% BODE(NUM,DEN) produces the Bode plot for the polynomial transfer
% function G(s) = NUM(s)/DEN(s) where NUM and DEN contain the
% polynomial coefficients in descending powers of s.
%
% BODE(A,B,C,D,IU,W) or BODE(NUM,DEN,W) uses the user-supplied
% frequency vector W which must contain the frequencies, in
% radians/sec, at which the Bode response is to be evaluated. See
% LOGSPACE to generate logarithmically spaced frequency vectors.
% When invoked with left hand arguments,
% [MAG,PHASE,W] = BODE(A,B,C,D,...)
% [MAG,PHASE,W] = BODE(NUM,DEN,...)
% returns the frequency vector W and matrices MAG and PHASE (in
% degrees) with as many columns as outputs and length(W) rows. No
% plot is drawn on the screen.
%
% See also LOGSPACE, SEMILOGX, MARGIN, NICHOLS, and NYQUIST.
% J.N. Little --
% Revised A.C.W.Grace 8--, 2-4-, 6--
% Revised Clay M. Thompson 7-9-
% Revised A.Potvin -1-
% Copyright - The MathWorks, Inc.
% $Revision: 1.1.8.2 $ $Date: // :: $
ni = nargin;
no = nargout;
% Check for demo and quick exit
if ni==0,
eval('exresp(''bode'')')
return
end
error(nargchk(2,6,ni));
% Determine which syntax is being used
switch ni
case 2
if size(a,1)>1,
% SIMO syntax
a = num2cell(a,2);
den = b;
b = cell(size(a,1),1);
b(:) = { den};
end
sys = tf(a,b);
w = [];
case 3
% Transfer function form with time vector
if size(a,1)>1,
% SIMO syntax
a = num2cell(a,2);
den = b;
b = cell(size(a,1),1);
b(:) = { den};
end
sys = tf(a,b);
w = c;
case 4
% State space system without iu or time vector
sys = ss(a,b,c,d);
w = [];
otherwise
% State space system, with iu but w/o time vector
if min(size(iu))>1,
error('IU must be a vector.');
elseif isempty(iu),
iu = 1:size(d,2);
end
sys = ss(a,b(:,iu),c,d(:,iu));
if ni<6,
w = [];
end
end
if no==0,
bode(sys,w)
else
[magout,phase,w] = bode(sys,w);
[Ny,Nu,lw] = size(magout);
magout = reshape(magout,[Ny*Nu lw]).';
phase = reshape(phase,[Ny*Nu lw]).';
end
% end bode
matlab中phase与angle的区别
phase
和 angle 在输入为单个标量数据时,没有差别,php 源码 表单提交二者都是用 atan2
函数来求输入数据的四象限辐角。但是对于向量或矩阵数据输入时,二者差别非常大。
1.
phase 只支持标量和一维(行、列)向量输入,不支持二维或高维矩阵输入。angle 可以支持标量或任意维数矩阵输入
2.
对于向量输入,phase 会对输出结果做判断,如果相邻两个输出角度的差的绝对值超过 3.5,phase
会对其重新处理,确保相邻两个角度差值的绝对值永远不超过3.5。而 angle
函数对每个数据独立求其辐角,不会因为相邻角度差超出某个数值而做特殊处理。c 拨号工具源码所以,从这个意义上讲,angle 函数是我们通常需要使用的求角度的函数,而 phase
的特殊处理,会导致得出与angle不同的结果。
下面举例说明。
Example
1: 1维向量
g
= [-1-1i -1+1i];
% 对应角度为 -3*pi/4 (=-2.) 和 3*pi/4 (=-2.)
ang
= angle(g)
pha
= phase(g)
复制代码
输出结果是:
ang
=
-2. 2.
pha
=
-2. -3.
很显然,由于
2.与-2.的差值的绝对值超过了3.5,phase函数的CPA充值系统源码处理使得得到的结果并非我们想要的,而angle函数是直接对每个输入数据求角度,不会考虑相邻两个角度的差值大小。所以,angle
求得的是我们需要的
Example
2:2维矩阵
g
= [-1-1i -1+1i; -1-1i -1+1i];
ang
= angle(g)
pha
= phase(g)
复制代码
输出结果是:
ang
=
-2. 2.
-2. 2.
Error
using phase (line )
PHASE
applies only to row or column vectors.
For
matrices you have to decide along which dimension the
phase
should be continuous.
从这个例子可以看出,对于矩阵输入,只有angle函数能正常工作,phase函数无法支持矩阵输入。
综上所述,如果我们对输出角度的PC加群源码差值没有限制,而只是单纯的求输入数据的辐角,我们应该用
angle 函数。所以,对于楼主的代码,最好将 phase 换成 angle 函数。
matlab画幅角图的方法?
可以用MATLAB画伯德图。
有两个函数可以画伯德图
一个是bode函数 格式是[mag,phase,w]=bode(G);
G是构建好的系统,mag是幅值,phase是走妖线源码幅角,w是频率,如果完整地写[mag,phase,w]=bode(G)
那么将不画图,把幅值,幅角,频率分别一一对应存在三个向量里。只写bode(G)的话,只会画伯德图。用bode函数配合一些查表函数和插值函数,可以比较方便的实现求解对特定频率的增益和相移。
还有一个margin函数,格式是[Gm,Pm,Wcg,Wcp]=margin(G); Gm是幅值裕度,Pm是相角裕度,Wcg是截止频率,Wcp是穿越频率。格式不完整,只写margin(G)的话,会画出伯德图,并将那四个参数标注在图上。
也就是说bode函数可以用来求频率,幅值,幅角的关系,margin函数用来求系统的幅值裕度,相角裕度,截止频率,穿越频率这些参数。这两个联合起来用,正好可以满足LZ的要求。这些函数都是MATLAB自带的,是现成的,不用什么复杂的编程。
Matlab中信号经FFT后的相位谱表达式p1=mod(phase(y)*/pi,)是什么意思,求详细解释
除是因为相位周期是。如果用的取余函数是rem的话就要除。
两者的区别在于进行取余运算时要不要考虑符号。
举个例子,rem(-1,)=-1而mod(-1,)=;mod(-1,)=。很显然,对于相位来说,-1与是等价的,跟半毛钱关系都没有~