傅里叶变换matlab程序

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

Fs=1000;%Samplingfrequency采样频率T=1/Fs;%Sampletime采样周期L=1000;%Lengthofsignal信号长度(点的个数)t=(0:L-1)*T;%Timevector时间向量(序列)(用来画图)%Sumofa50Hzsinusoidanda120Hzsinusoid一个50赫兹正弦加上120赫兹正弦x=0.7*sin(2*pi*50*t)+sin(2*pi*120*t);y=x+2*randn(size(t));%Sinusoidsplusnoise正弦之和加上正态噪声figure(1);plot(Fs*t(1:50),y(1:50))title('SignalCorruptedwithZero-MeanRandomNoise')%被零均值噪声祸害的信号xlabel('time(milliseconds)')%Itisdifficulttoidentifythefrequencycomponentsbylookingattheoriginalsignal.Convertingtothefrequencydomain,thediscreteFouriertransformofthenoisysignalyisfoundbytakingthefastFouriertransform(FFT):%从时域上直接看原信号难以确定各频率分量.通过使用快速傅里叶变换FFT,实现了含噪声信号Y的离散傅里叶变换,从而把信号转换到频域上(确定频率分量)NFFT=2^nextpow2(L);%Nextpowerof2fromlengthofyY=fft(y,NFFT)/L;f=Fs/2*linspace(0,1,NFFT/2+1);%Plotsingle-sidedamplitudespectrum.figure(2);plot(f,2*abs(Y(1:NFFT/2+1)))title('Single-SidedAmplitudeSpectrumofy(t)')xlabel('Frequency(Hz)')ylabel('|Y(f)|')A=xlsread('SHUJU2.xlsx');%这里的SHUJU1.xlsx是数据FS=1000;%FS是采样率T=1/FS;L=length(A)t=(0:L-1)*T;figure(3);plot(FS*t(1:50),A(1:50));title('SignalCorruptedwithZero-MeanRandomNoise')%被零均值噪声祸害的信号xlabel('time(milliseconds)')figure(6);NFFT=2^nextpow2(L)%nextpow2(L)使得2^p=L的最小的pY=fft(A,NFFT)/L;f=FS/2*linspace(0,1,NFFT/2+1);plot(f,2*abs(Y(1:NFFT/2+1)));title('Single-SidedAmplitudeSpectrumofy(t)')xlabel('Frequency(Hz)')ylabel('|Y(f)|')

1 / 2
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功