欢迎来到天天文库
浏览记录
ID:16385931
大小:148.16 KB
页数:8页
时间:2018-08-09
《matlab谱分析入门》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、例题波数据:图形如下:练习傅里叶变换,求系数a,b,利用公式(注意N为偶数):前者称为正变换,后者称为逆变换。振幅和相位:功率:Matlab程序(注意matlab中数组下标从1开始,故循环中数组下标加1):clc;cleara=zeros(1,9);b=zeros(1,9);x=[53238-33-19-101-8-2010-1411-1-7-2];n=length(x);fork=0:1:n/2form=0:n-1a(k+1)=a(k+1)+x(m+1)*cos((2*pi*k*m)/n);b(k+1)=b(k+1)+x(m+1)*sin((2*pi*k*
2、m)/n);endenda=2/n*ab=2/n*by=zeros(1,16);form=0:n-1fork=1:1:n/2-1y(m+1)=y(m+1)+a(k+1)*cos(2*pi*k*m/n)+b(k+1)*sin(2*pi*k*m/n);endy(m+1)=y(m+1)+a(1)/2+a(n/2+1)/2*cos(2*pi*(n/2)*m/n);endyz=(a.^2+b.^2).^0.5fai=atan(-b./a);p0=0;form=0:n-1p0=p0+x(m+1)^2;endp0=1/n*p0p=z.^2/2;p(9)=p(9)/2;p运
3、行结果如下:a=07.75925.48904.9579-6.7500-4.1880-7.23903.97092.0000b=0-4.14278.380211.95248.7500-3.8561-2.3698-4.95120.0000y=5.000032.000038.0000-33.0000-19.0000-10.00001.0000-8.0000-20.000010.0000-1.00004.000011.0000-1.0000-7.0000-2.0000z=08.795910.017812.939911.05105.69297.61706.34682.0
4、000p0=300p=038.683750.178383.721061.062516.204329.009220.14101.0000复数形式:clc;clearc=zeros(1,16);x=[53238-33-19-101-8-2010-1411-1-7-2];n=length(x);a0=sum(x)/length(x);fork=0:n-1form=0:n-1c(k+1)=c(k+1)+x(m+1)*(cos((2*pi*k*m)/n)-i*sin((2*pi*k*m)/n));endendc=1/n*cp=abs(c)y=zeros(1,16);f
5、orm=0:n-1fork=0:n-1y(m+1)=y(m+1)+c(k+1)*exp(i*2*pi*k*m/n);endendy运行结果:c=03.8796+2.0713i2.7445-4.1901i2.4790-5.9762i-3.3750-4.3750i-2.0940+1.9280i-3.6195+1.1849i1.9854+2.4756i1.0000-0.0000i1.9854-2.4756i-3.6195-1.1849i-2.0940-1.9280i-3.3750+4.3750i2.4790+5.9762i2.7445+4.1901i3.8796-
6、2.0713ip=04.39795.00896.47005.52552.84643.80853.17341.00003.17343.80852.84645.52556.47005.00894.3979y=5.0000-0.0000i32.0000-0.0000i38.0000-0.0000i-33.0000+0.0000i-19.0000-0.0000i-10.0000-0.0000i1.0000+0.0000i-8.0000+0.0000i-20.0000+0.0000i10.0000+0.0000i-1.0000-0.0000i4.0000+0.0000
7、i11.0000-0.0000i-1.0000+0.0000i-7.0000-0.0000i-2.0000-0.0000i快速傅里叶变换(FFT)matlab程序(注意要对坐标进行变换以显示一半):clc;clearx=[53238-33-19-101-8-2010000000]x1=[53238-33-19-101-8-2010]y=fft(x);y1=fft(x1);plot(2/length(x)*([0:length(x)/2]),abs(y(1:(length(x)/2+1))/2),'r--o');holdonplot(2/length(x1)*
8、([0:length(x1)/2]),abs(y1(
此文档下载收益归作者所有