Pages

Selasa, 03 Juli 2012

Matlab : Fourier Transform

%progam deskret fourier series
clear all; clc;
dt=0.5; %sampling rate
T=4; %periode
N=T/dt; %jumlah sampel
t=[0:dt:(N-1)*dt];%deret waktu
k=[1:length(t)];%indeks waktu --->harus dimulai dg angka 1
df=1/(N*dt)%sampling frekuensi
fnyq = 1/(2*dt)%frek maksimum (Nyquist frek)
freq = [0:df:fnyq]%deret frek
x = [1;1;1;0;0;0;1;1];%amplitudo dlm domain waktu {f(k.dt)}
%matrix W
for k=1:N
    for i=1;length(freq)
        W(i,k) = cos((i-1)*2*(pi/T)*0.5*(k-1))
    end
end
   
a=(1/N)*W*x

figure(3)
subplot(2,1,1)
plot(t,x,'ok','markerfacecolor','b')
grid on
subplot(2,1,2)
plot(freq,a,'ok','markerfacecolor','k')
grid on

0 komentar:

Posting Komentar

next page