实验用Matlab基本函数

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

实验用Matlab基本函数

1.abs

Absolute value (magnitude)

Syntax

y = abs(x)

Description

y = abs(x) returns the absolute value of the elements of x. If x is complex, abs returns the complex modulus (magnitude).

abs(x) = sqrt(real(x).^2 + imag(x).^2)

If x is a MATLAB string, abs returns the numeric values of the ASCII characters in the string. The display format of the string changes; the internal representation does not.

The abs function is part of the standard MATLAB language.

Example

Calculate the magnitude of the FFT of a sequence.

t = (0:99)/100; % time vector

x = sin(2*pi*15*t) + sin(2*pi*40*t); % signal

y = fft(x); % compute DFT of x

m = abs(y); % magnitude

Plot the magnitude.

f = (0:length(y)-1)'/length(y)*100; % frequency vector

plot(f,m)

2. angle

Phase angle

Syntax

p = angle(h)

Description

p = angle(h) returns the phase angles, in radians, of the elements of complex vector or array h. The phase angles lie between - and .

For complex sequence h = x + iy = meip, the magnitude and phase are given by

m = abs(h)

p = angle(h)

To convert to the original h from its magnitude and phase, type

i = sqrt(-1)

h = m.*exp(i*p)

The angle function is part of the standard MATLAB language.

Example

Calculate the phase of the FFT of a sequence.

t = (0:99)/100; % time vector

x = sin(2*pi*15*t) + sin(2*pi*40*t); % signal

y = fft(x); % compute DFT of x

p = unwrap(angle(y)); % phase

Plot the phase.

f = (0:length(y)-1)'/length(y)*100; % frequency vector

plot(f,p)

Algorithm

angle can be expressed as

angle(x) = imag(log(x)) = atan2(imag(x),real(x))

3. besself

Bessel analog filter design

Syntax

[b,a] = besself(n,Wn)

[b,a] = besself(n,Wn,'ftype')

[z,p,k] = besself(...)

[A,B,C,D] = besself(...)

Description

besself designs lowpass, bandpass, highpass, and bandstop analog Bessel filters. Analog Bessel filters are characterized by almost constant group delay across the entire passband, thus preserving the wave shape of filtered signals in the passband. Digital Bessel filters do not retain this quality, and besself therefore does not support the design of digital Bessel filters.

[b,a] = besself(n,Wn) designs an order n lowpass analog filter with cutoff frequency Wn. It returns the filter coefficients in the length n+1 row vectors b and a, with coefficients in descending powers of s, derived from the transfer function

)

1()()2()1()()2()1()()()(11++++++++++==--n a s n a s a s n b s n b s b s b s A s B s H n n n n Cutoff frequency is the frequency at which the magnitude response of the filter begins to decrease significantly. For besself, the cutoff frequency Wn must be greater than 0. The magnitude response of a Bessel filter designed by besself is always less than 21 at the cutoff frequency,

相关文档
最新文档