- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是我用来在 Matlab 中绘制频域函数的代码:
dt = 1/10000; % sampling rate
et = 0.1; % end of the interval
t = 0:dt:et; % sampling range
y = 2+sin(2.*pi.*50.*t)+18.*sin(2.*pi.*90.*t)+6.*sin(2.*pi.*180.*t); % sample the signal
subplot(2,1,1); % first of two plots
plot(t,y); grid on % plot with grid
xlabel('Time (s)'); % time expressed in seconds
ylabel('Amplitude'); % amplitude as function of time
Y = fft(y); % compute Fourier transform
n = size(y,2)/2; % 2nd half are complex conjugates
amp_spec = abs(Y)/n; % absolute value and normalize
subplot(2,1,2); % second of two plots
freq = (0:100)/(2*n*dt); % abscissa viewing window
stem(freq,amp_spec(1:101)); grid on % plot amplitude spectrum
xlabel('Frequency (Hz)'); % 1 Herz = number of cycles/second
ylabel('Amplitude'); % amplitude as function of frequency
问题是,当我放大图表时,我看不到 50Hz、90Hz 和 180Hz 上的峰值。
我的代码做错了什么?
最佳答案
问题在于,为了获得完美的频谱(峰值在 50、90、180 处,否则为 0),您的间隔应该是所有频率的乘数。
解释:考虑 y=sin(2.*pi.*t)
。使用您的代码绘制它:
1) et = 1-dt;
2) et = 1;
在第一种情况下,如果放大,您会看到峰值完全位于 1 Hz。在第二种情况下,它不是(也非常接近)。
为什么?因为您使用的是有限数量的点,因此也是有限数量的频率。如果 1 Hz 在这组频率中(第一种情况),您将在 1 Hz 处获得完美的峰值,而在所有其他频率处为零。
在情况 2 中,您的集合中没有 1 Hz 频率,因此您将在最近的频率上获得峰值(并且它的宽度也是有限的)。
最终,在您的原始代码中,您的全套频率中没有 50、90、180 Hz 频率。
关于matlab - Matlab中信号的频谱,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29500447/
我对复值频谱执行 iFFT 并通过让第一个样本归零来更改相应的时域信号。最后,我通过 FFT 将其转换回频域。 我想知道这里使用两侧(对称)频谱或仅使用一侧频谱(仅正频率)之间的(物理)差异在哪里,因
我正在尝试提高使用 cython 计算 Jonswap 频谱的性能。但它似乎比原始代码慢得多。我该如何改进? 赛通代码: from libc.math cimport exp from libc.st
我目前可以使用 JavaScript Web Audio API 播放音轨。在播放此轨道时,我可以提取 FFT 频谱数据、峰值、RMS 值等。 但是,出于我的应用程序的目的,我需要能够在开始播放轨道之
我正在尝试将频谱保存在我的 FMOD_DSP_PARAMETER_FFT 中,但我只收到充满零的频谱,如果你能看到我的错误我会同意,我认为我没有很好地将 DSP 连接到 channel 或类似的东西,
我有一个复杂的信号,我想对其进行 FFT。使用 Mathematica 我得到以下结果: (* Some acquisition params *) fS = 100. 10^6; time = 10
我是一名优秀的程序员,十分优秀!