atan和unwrap解卷绕

要计算一个系统相频特性,就要用到反正切函数,计算机中反正切函数规定,在一、二象限中的角度为0~pi,三四象限的角度为0~-pi。

若一个角度从0变到2pi,但实际得到的结果是0~pi,再由-pi~0,在w=pi处发生跳变,跳变幅度为2pi,这就叫相位的卷绕。
unwrap(w)就是解卷绕,使相位在pi处不发生跳变,从而反应出真实的相位变化 "

查看 unwrap 的帮助文档可以发现 unwrap 还可以输入一个参数 tol,默认tol = pi。也许你需要根据情况修改下 tol。

 

 

对于一般的数列,直接使用unwrap(pha)就可以了

unwrap功能检查出数据相位跳变,并纠正跳变
实际上在检查是否跳变的时候是有个标准的
unwrap(pha,tol)
这个tol就是标准,在默认的情况下,这个标准是pi
也就是说unwrap在检查到数据前后两点的差距在超过tol的时候,就认为有跳变
然后就回处理数据,让后面的数据加2pi或者减2pi是数据连续
大部分情况下使用pi这个标准都比较合适,所以第二个参数可以缺省
特殊情况下是可以通过设置tol调整鉴别标准

而unwrap函数不单能对数列作用,还能对矩阵作用
实现对矩阵每一行或者每一列实施相位矫正
所以完整的格式是unwrap(pha,tol,dim)
最后一个参数dim表示需要对矩阵的行,还是列进行unwrap操作
如果对列每一列操作,那么第三个参数可以缺省
而要对每一行操作,那么第三个参数填2

unwrap(pha,[],2)

表示对矩阵phi中的相位数据,每一行实施相位矫正
使用默认的检测跳变标准

UNWRAP(P) unwraps radian phases P by changing absolute
jumps greater than or equal to pi to their 2*pi complement.
It unwraps along the first non-singleton dimension of P
and leaves the first phase value along this dimension
unchanged. P can be a scalar, vector, matrix, or N-D array.

UNWRAP(P,TOL) uses a jump tolerance of TOL rather
than the default TOL = pi.

UNWRAP(P,[],DIM) unwraps along dimension DIM using the
default tolerance. UNWRAP(P,TOL,DIM) uses a jump tolerance
of TOL.

Class support for input P:
float: double, single

See also ANGLE, ABS.

Copyright 1984-2005 The MathWorks, Inc.

Overview of the algorithm:
Reshape p to be a matrix of column vectors. Perform the
unwrap calculation column-wise on this matrix. (Note that this is
equivalent to performing the calculation on dimension one.)
Then reshape the output back.

posted @ 2017-08-18 20:32  喵喵小学僧  阅读(867)  评论(0编辑  收藏  举报