【发布时间】:2017-05-02 08:33:58
【问题描述】:
我在 MATLAB 中有用于信号(音频信号)代码的 FFT,但它显示(绘制)图形。但是我只想将频率分量存储在一个变量中,但我不知道如何。 如果代码不适用,任何人都可以给我在 Matlab 或 Java 中工作的代码吗?
注意:我不是信号处理或 MATLAB 方面的专家。
%% Basic Fourier Analysis
% This example uses the Fourier transform to identify component
% frequencies in a simple signal.
%%
% Create a time vector |t| and a sinusoidal signal |x| that is a function of |t|.
t = 0:1/50:10-1/50;
x = sin(2*pi*15*t) + sin(2*pi*20*t);
%%
% Plot the signal as a function of time.
plot(t,x)
%%
% Compute the Fourier transform of the signal, and then compute the magnitude
% |m| and phase |p| of the signal.
y = fft(x);
m = abs(y);
p = angle(y);
%%
% Compute the frequency vector associated with the signal |y|, which is
% sampled in frequency space.
f = (0:length(y)-1)*50/length(y);
%%
% Plot the magnitude and phase of the signal as a function of frequency.
% The spikes in magnitude correspond to the signal's frequency
% components.
subplot(2,1,1)
plot(f,m)
title('Magnitude')
subplot(2,1,2)
plot(f,rad2deg(p))
title('Phase')
%%
% Compute and plot the inverse transform of $y$, which reproduces the
% original data in $x$ up to round-off error.
figure
x2 = ifft(y);
plot(t,x2)
【问题讨论】:
-
请展示您的尝试。据我了解,这段代码不是你写的。
-
是的,我在 matlab 网站上找到了它
-
我尝试像这样存储它 h=fft(t,x2) 然后 x_h=h.x y_h=h.y
标签: java matlab signals signal-processing fft