傅里叶变换matlab程序

  • 格式:doc
  • 大小:21.40 KB
  • 文档页数:3

下载文档原格式

  / 5
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

Fs = 1000; % Sampling frequency采样频率

T = 1/Fs; % Sample time采样周期

L = 1000; % Length of signal信号长度(点的个数)

t = (0:L-1)*T; % Time vector时间向量(序列)(用来画图)

% Sum of a 50 Hz sinusoid and a 120 Hz sinusoid一个50赫兹正弦加上120赫兹正弦

x = 0.7*sin(2*pi*50*t) + sin(2*pi*120*t);

y = x + 2*randn(size(t)); % Sinusoids plus noise正弦之和加上正态噪声

figure(1);

plot(Fs*t(1:50),y(1:50))

title('Signal Corrupted with Zero-Mean Random Noise')%被零均值噪声祸害的信号

xlabel('time (milliseconds)')

%It is difficult to identify the frequency components by looking at the original signal. Converting to the frequency domain, the discrete Fourier transform of the noisy signal y is found by taking the fast Fourier transform (FFT):

%从时域上直接看原信号难以确定各频率分量. 通过使用快速傅里叶变换FFT, 实现了含噪声信号Y的离散傅里叶变换,从而把信号转换到频域上(确定频率分量)

NFFT = 2^nextpow2(L); % Next power of 2 from length of y

Y = fft(y,NFFT)/L;

f = Fs/2*linspace(0,1,NFFT/2+1);

% Plot single-sided amplitude spectrum.

figure(2);

plot(f,2*abs(Y(1:NFFT/2+1)))

title('Single-Sided Amplitude Spectrum of y(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('Signal Corrupted with Zero-Mean Random Noise')%被零均值噪声祸害的信号

xlabel('time (milliseconds)')

figure(6);

NFFT = 2^nextpow2(L) % nextpow2(L)使得2^p>=L的最小的p

Y = fft(A,NFFT)/L;

f = FS/2*linspace(0,1,NFFT/2+1);

plot(f,2*abs(Y(1:NFFT/2+1)));

title('Single-Sided Amplitude Spectrum of y(t)')

xlabel('Frequency (Hz)')

ylabel('|Y(f)|')

THANKS !!!

致力为企业和个人提供合同协议,策划案计划书,学习课件等等

打造全网一站式需求

欢迎您的下载,资料仅供参考