% xfft.m
%
% ƒ@Fourier Tansform „
%
Fs = 200;
% ƒTƒ“ƒvƒŠƒ“ƒOŽü”g” (Hz)
T = 1;
% ŠÏ‘ªŽžŠÔi1secj
dt = 1/Fs;
% ŽžŠÔ•ª‰ð”\iƒTƒ“ƒvƒŠƒ“ƒOŠÔŠuj
N = T/dt;
% ƒTƒ“ƒvƒ‹”
t = (0:dt:T-dt);
% time vector
%
%
----------------------signal---------------------------
x = cos(2*pi*10*t) + sin(2*pi*50*t); % M†iŽžŒn—ñƒf[ƒ^j
figure(1)
subplot(411); plot(x); legend('signal'); % ŠÏ‘ªM†‚̃vƒƒbƒg
%
% ----------------fast fourier
tansform------------------
w = fft(x)/N;
subplot(412); plot(real(w));
% ƒt[ƒŠƒGŒW”iŽÀ•”j
legend('fourier coefficient (real)');
subplot(413); plot(imag(w));
% ƒt[ƒŠƒGŒW”i‹••”j
legend('fourier coefficient (imagenary)');
subplot(414); plot(abs(w));
% ƒt[ƒŠƒGŒW”iâ‘Î’lj
legend('fourier coefficient (absolute value)');
%
% ------------------Perseval
theorem---------------------
pwrt = sum(x.^2)/N
pwrf = sum(abs(w).^2)
%
-------------------------------------------------------
% 2002.4.29 by K.Tsukada