实验用matlab基本函数

上传人:第*** 文档编号:31777134 上传时间:2018-02-09 格式:DOC 页数:24 大小:178.10KB
返回 下载 相关 举报
实验用matlab基本函数_第1页
第1页 / 共24页
实验用matlab基本函数_第2页
第2页 / 共24页
实验用matlab基本函数_第3页
第3页 / 共24页
实验用matlab基本函数_第4页
第4页 / 共24页
实验用matlab基本函数_第5页
第5页 / 共24页
点击查看更多>>
资源描述

《实验用matlab基本函数》由会员分享,可在线阅读,更多相关《实验用matlab基本函数(24页珍藏版)》请在金锄头文库上搜索。

1、第 1 页 共 24 页实验用 Matlab 基本函数1.absAbsolute value (magnitude)Syntaxy = abs(x)Descriptiony = 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

2、 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.ExampleCalculate the magnitude of the FFT of a sequence.t = (0:99)/100; % time vectorx = sin(2*pi*15*t) + sin(2*pi*40*t); % sig

3、naly = fft(x); % compute DFT of xm = abs(y); % magnitudePlot the magnitude.f = (0:length(y)-1)/length(y)*100; % frequency vectorplot(f,m)2. anglePhase angleSyntaxp = angle(h)Descriptionp = angle(h) returns the phase angles, in radians, of the elements of complex vector or array h. The phase angles l

4、ie between - and .For complex sequence h = x + iy = meip, the magnitude and phase are given bym = abs(h)p = angle(h)To convert to the original h from its magnitude and phase, type第 2 页 共 24 页i = sqrt(-1)h = m.*exp(i*p)The angle function is part of the standard MATLAB language.ExampleCalculate the ph

5、ase of the FFT of a sequence.t = (0:99)/100; % time vectorx = sin(2*pi*15*t) + sin(2*pi*40*t); % signaly = fft(x); % compute DFT of xp = unwrap(angle(y); % phasePlot the phase.f = (0:length(y)-1)/length(y)*100; % frequency vectorplot(f,p)Algorithmangle can be expressed asangle(x) = imag(log(x) = ata

6、n2(imag(x),real(x)3. besselfBessel analog filter designSyntaxb,a = besself(n,Wn)b,a = besself(n,Wn,ftype)z,p,k = besself(.)A,B,C,D = besself(.)Descriptionbesself designs lowpass, bandpass, highpass, and bandstop analog Bessel filters. Analog Bessel filters are characterized by almost constant group

7、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 cutof

8、f 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)(1nassabbsABHnnLCutoff frequency is the frequency at which the magnitude response of the filter begins to decrease signific

9、antly. 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 at the cutoff frequency, 21第 3 页 共 24 页and it decreases as the order n increases.If Wn is a two-element vector, Wn = w1 w2 with w1 w2, then besself(n,

10、Wn) returns an order 2*n bandpass analog filter with passband w1 w2.b,a = besself(n,Wn,ftype) designs a highpass or bandstop filter, where thestring ftype is: high for a highpass analog filter with cutoff frequency Wn stop for an order 2*n bandstop analog filter if Wn is a two-element vector,Wn = w1

11、 w2The stopband is w1 w2.With different numbers of output arguments, besself directly obtains other realizations of the analog filter. To obtain zero-pole-gain form, use three output arguments as shown below.z,p,k = besself(n,Wn) orz,p,k = besself(n,Wn,ftype) returns the zeros and poles in length n

12、or 2*n column vectors z and p and the gain in the scalar k.Algorithmbesself performs a four-step algorithm: It finds lowpass analog prototype poles, zeros, and gain using the besselapfunction. It converts the poles, zeros, and gain into state-space form. It transforms the lowpass filter into a bandp

13、ass, highpass, or bandstop filterwith desired cutoff frequencies using a state-space transformation. It converts the state-space filter back to transfer function or zero-pole-gain form, as required.4. bilinearBilinear transformation method for analog-to-digital filter conversionSyntaxzd,pd,kd = bili

14、near(z,p,k,fs)zd,pd,kd = bilinear(z,p,k,fs,Fp)numd,dend = bilinear(num,den,fs)numd,dend = bilinear(num,den,fs,Fp)Ad,Bd,Cd,Dd = bilinear(A,B,C,D,fs)Ad,Bd,Cd,Dd = bilinear(A,B,C,D,fs,Fp)DescriptionThe bilinear transformation is a mathematical mapping of variables. In digital filtering, it is a 第 4 页 共

15、 24 页standard method of mapping the s or analog plane into the z or digital plane. It transforms analog filters, designed using classical filter design techniques, into their discrete equivalents.Zero-Pole-Gainzd,pd,kd = bilinear(z,p,k,fs) andzd,pd,kd = bilinear(z,p,k,fs,Fp) convert the s-domain transfer function specified by z, p, and k to a discrete equivalent. Inputs z and p are column vectors containing the zeros and poles, k is a scalar gain, and fs is the sampling frequency in hertz. bilinear returns the discrete equivalent in column vectors zd and pd and sc

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 行业资料 > 工业设计

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号