[英]Fourier transform and FFT for an arbitrary plot using MATLAB
我有一个简单的问题,但是由于我没有使用过MATLAB Fourier变换工具,因此需要一些帮助。 我有一个从n excel文件获得的图。 该图在时域中。 绘图的时间范围是0到50 ps。 我每0.5 fs就有图的y分量的数据。 基本上,该图包含每0.5fs打印的100000个数据。 现在,我想获得此图的傅立叶变换。 我该怎么办? 以下是我的excel文件的一种简单格式,其中包括进行时域图所需的数据。
0 116.0080214
0.0005 116.051128
0.001 116.0939229
0.0015 116.1362197
0.002 116.1776665
0.0025 116.2178118
0.003 116.256182
.
.
.
.
50.0 123.000
第一列是以秒为单位的时间。 提前非常感谢您的帮助。 最好,HRJ
我已针对解决方案调整了此页面 。
Fs = 100000/50; % Sampling frequency (in 1/ps)
T = 1/Fs; % Sample time (in ps)
L = 100000; % Length of signal
t = (0:L-1)*T; % Time vector; your first column should replace this
% Sum of a 50 1/ps sinusoid and a 120 1/ps sinusoid
% Your second column would replace y
x = 0.7*sin(2*pi*50*t) + sin(2*pi*120*t);
y = x + 2*randn(size(t)); % Sinusoids plus noise
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);
close all
subplot(2,1,1)
% Plot your original signal
plot(Fs*t(1:100),y(1:100))
title('Signal Corrupted with Noise')
xlabel('time (fs)')
% Plot single-sided amplitude spectrum.
subplot(2,1,2)
plot(f,2*abs(Y(1:NFFT/2+1)))
title('Single-Sided Amplitude Spectrum of y(t)')
xlabel('Frequency (1/ps)')
ylabel('|Y(f)|')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.