【发布时间】:2018-07-14 22:52:12
【问题描述】:
我想绘制粗糙度的轮廓(来自 AFM 测量),但我仍然对 FFT 有误解(尤其是在 Matlab 文档中)。
我想比较两个测量值,也就是两个粗糙度曲线。它们是在同一个表面上完成的,它们只是在一个比另一个的长度短这一事实上有所不同。不过,对于每个配置文件,我都有相同数量的样本度量(这里 N=512)。假设这些是我的配置文件,t10 和 t100 是进行测量的 x 横坐标,d10 和 d100 是垂直坐标,a.k.粗糙度轮廓中测量的高度。
N=512;
t10 = linspace(0,10, N);
t100= linspace(0,100, N);
d10 = sin(2*pi*0.23 .*t10)+cos(2*pi*12 .*t10);
d100 = sin(2*pi*0.23 .*t100)+cos(2*pi*12 .*t100);
由于我测量的是同一个表面,但具有不同的空间分辨率,即不同的采样周期,这些粗糙度剖面的单面振幅谱应该重叠,不是吗?
使用以下函数:
function [f,P1,S1] = FFT_PowerSpectrumDensity(time,signal,flagfig)
H=signal;
X=time;
ell=length(X);
L = ell;% 2^(nextpow2(ell)-1) % Next power of 2 from length of the signal
deltaTime = mean(diff(X));
Fs=1/deltaTime; %% mean sampling frequency
%% Compute the Fourier transform of the signal.
Y = fft(H);
%% Compute the two-sided spectrum P2. Then compute the single-sided spectrum P1 based on P2 and the even-valued signal length L.
P2 = abs(Y/L); % abs(fft(signal Y)) / Length_of_signal
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;
if flagfig~=0
figure(flagfig)
loglog(f,P1)
title('Single-Sided Amplitude Spectrum of X(t)','FontSize',18)
xlabel('Spatial frequency f=1/\lambda (m^{-1})','FontSize',14)
ylabel('|P1(f)| (m)','FontSize',14)
end
S = (Y.*conj(Y)).*(2/L).^2; % power spectral density
S1 = S(1:L/2+1);
S1(2:end-1) = S1(2:end-1);
%% Power spectrum (amplitude = a^2+b^2), in length^2
if flagfig~=0
figure(flagfig+1)
loglog(f,S1)
title('Power spectrum','FontSize',18)
xlabel('Spatial frequency f=1/\lambda (m^{-1})','FontSize',14)
ylabel('(Y*2/L)^2 (m^2)','FontSize',14)
end
end
例如,我使用以下命令调用此函数:
[f10, S10]= FFT_PowerSpectrumDensity(t10, d10, 10);
我应该使用L=2^pow2(ell)-1) 吗?我知道它为 FFT 函数提供了更好的输入?另外,我不太确定我应该找到的大多数单位和值。
感谢您的帮助、更正和建议。
【问题讨论】:
标签: matlab signal-processing fft spectrum