傅裡葉變換—信号觀測時長和頻率分辨率
前言
一、開始驗證
附錄
MATLAB代碼:
%% observe time T and frequency resolution verified
f1 = 1; %the frequency of child signal 1
f2 = 1.5; %the frequency of child signal 2 Unit Hz
Fs = 50; %sampling rate , Unit Hz
delta_t = 1/Fs;
% t = 0:delta_t:1-delta_t; %the total time length is 1s, contains 1 peroid of singal 1 and 1.5 peiod of singal 2
t = 0:delta_t:2-delta_t; %the total time length is 2s, contains 2 peroid of singal 1 and 3 peiod of singal 2
s1 = sin(2*pi*f1.*t); %child signal 1
s2 = sin(2*pi*f2.*t); %child signal 2
s = s1 + s2; %signal;
N = length(t); %signal length and frequency axis length;
fft_s1 = fft(s1,N); %fft of child signal 1
fft_s2 = fft(s2,N); %fft of child signal 2
fft_s = fft(s,N); %fft of signal
delta_f = Fs/N; %resolution of frequncy
axis_f = (0:N-1)*delta_f; %frequency axis
figure(1);
subplot(2,2,1)
plot(t,s1); %plot signal 1
hold on
plot(t,s2,'-'); %plot signal 2
xlabel('time s');
ylabel('signal');
title('time domain wave');
legend('child signal 1','child signal 2');
subplot(2,2,3)
plot(axis_f, abs(fft_s1)); %spectrum of signal 1;
hold on
plot(axis_f, abs(fft_s2),'-'); %spectrum of signal 2;
xlabel('frequency Hz');
ylabel('fft result');
title('observation time 1s');
legend('child signal 1','child signal 2');
subplot(2,2,2)
plot(t,s); %plot signal
xlabel('time s');
ylabel('signal');
title('time domain wave');
subplot(2,2,4)
plot(axis_f, abs(fft_s)); %spectrum of signal 1;
xlabel('frequency Hz');
ylabel('fft result');
title('observation time 1s');
% %separately observe the spectrum of signal that not full period
% f1 = 1; %the frequency of child signal 1
% f2 = 1.5; %the frequency of child signal 2 Unit Hz
% Fs = 50; %sampling rate , Unit Hz
% delta_t = 1/Fs;
% % t = 0:delta_t:1-delta_t; %the total time length is 1s, contains 1 peroid of singal 1 and 1.5 peiod of singal 2
% t = 0:delta_t:2-delta_t; %the total time length is 2s, contains 2 peroid of singal 1 and 3 peiod of singal 2
% s1 = sin(2*pi*f1.*t); %child signal 1
% s2 = sin(2*pi*f2.*t); %child signal 2
% s = s1 + s2; %signal;
% N = 500000; %fft number in order to observe more detailed
% fft_s1 = fft(s1,N); %fft of child signal 1
% fft_s2 = fft(s2,N); %fft of child signal 2
% fft_s = fft(s,N); %fft of signal
% delta_f = Fs/N; %resolution of frequncy
% axis_f = (0:N-1)*delta_f; %frequency axis
% figure(1);
% subplot(2,2,1)
% plot(t,s1); %plot signal 1
% hold on
% plot(t,s2,'-'); %plot signal 2
% xlabel('time s');
% ylabel('signal');
% title('time domain wave');
% legend('child signal 1','child signal 2');
% subplot(2,2,3)
% plot(axis_f, abs(fft_s1)); %spectrum of signal 1;
% hold on
% plot(axis_f, abs(fft_s2),'-'); %spectrum of signal 2;
% xlabel('frequency Hz');
% ylabel('fft result');
% title('observation time 1s');
% legend('child signal 1','child signal 2');
%
%
% subplot(2,2,2)
% plot(t,s); %plot signal
% xlabel('time s');
% ylabel('signal');
% title('time domain wave');
% subplot(2,2,4)
% plot(axis_f, abs(fft_s)); %spectrum of signal 1;
% xlabel('frequency Hz');
% ylabel('fft result');
% title('observation time 1s');