资源描述:
《实验用Matlab基本函数》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、实验用Matlab基本函数1.absAbsolutevalue(magnitude)Syntaxy=abs(x)Descriptiony=abs(x)returnstheabsolutevalueoftheelementsofx.Ifxiscomplex,absreturnsthecomplexmodulus(magnitude).abs(x)=sqrt(real(x).^2+imag(x).^2)IfxisaMATLABstring,absreturnsthenumericvaluesoftheASCIIc
2、haractersinthestring.Thedisplayformatofthestringchanges;theinternalrepresentationdoesnot.TheabsfunctionispartofthestandardMATLABlanguage.ExampleCalculatethemagnitudeoftheFFTofasequence.t=(0:99)/100;%timevectorx=sin(2*pi*15*t)+sin(2*pi*40*t);%signaly=fft(x);
3、%computeDFTofxm=abs(y);%magnitudePlotthemagnitude.f=(0:length(y)-1)'/length(y)*100;%frequencyvectorplot(f,m)2.anglePhaseangleSyntaxp=angle(h)Descriptionp=angle(h)returnsthephaseangles,inradians,oftheelementsofcomplexvectororarrayh.Thephaseanglesliebetween-a
4、nd.Forcomplexsequenceh=x+iy=meip,themagnitudeandphasearegivenbym=abs(h)p=angle(h)Toconverttotheoriginalhfromitsmagnitudeandphase,type第24页共24页i=sqrt(-1)h=m.*exp(i*p)TheanglefunctionispartofthestandardMATLABlanguage.ExampleCalculatethephaseoftheFFTofasequence
5、.t=(0:99)/100;%timevectorx=sin(2*pi*15*t)+sin(2*pi*40*t);%signaly=fft(x);%computeDFTofxp=unwrap(angle(y));%phasePlotthephase.f=(0:length(y)-1)'/length(y)*100;%frequencyvectorplot(f,p)Algorithmanglecanbeexpressedasangle(x)=imag(log(x))=atan2(imag(x),real(x))
6、3.besselfBesselanalogfilterdesignSyntax[b,a]=besself(n,Wn)[b,a]=besself(n,Wn,'ftype')[z,p,k]=besself(...)[A,B,C,D]=besself(...)Descriptionbesselfdesignslowpass,bandpass,highpass,andbandstopanalogBesselfilters.AnalogBesselfiltersarecharacterizedbyalmostconst
7、antgroupdelayacrosstheentirepassband,thuspreservingthewaveshapeoffilteredsignalsinthepassband.DigitalBesselfiltersdonotretainthisquality,andbesselfthereforedoesnotsupportthedesignofdigitalBesselfilters.[b,a]=besself(n,Wn)designsanordernlowpassanalogfilterwi
8、thcutofffrequencyWn.Itreturnsthefiltercoefficientsinthelengthn+1rowvectorsbanda,withcoefficientsindescendingpowersofs,derivedfromthetransferfunctionCutofffrequencyisthefrequencyatwhichthemagnituderespo