资源预览内容
第1页 / 共24页
第2页 / 共24页
第3页 / 共24页
第4页 / 共24页
第5页 / 共24页
第6页 / 共24页
第7页 / 共24页
第8页 / 共24页
第9页 / 共24页
第10页 / 共24页
亲,该文档总共24页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
第 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 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); % signaly = 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 lie 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 phase 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) = atan2(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 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)(1nassabbsABHnnLCutoff 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 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,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 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 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 bandpass, 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 = bilinear(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 页 共 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
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号