Berikut ini adalah script MATLAB untuk melakukan transformasi Fourier signal discrete tanpa menggunakan function fft().
x=input('Input signal: ');
len=length(x);
y=zeros(1,len);%create an array
yabs=zeros(1,len);%this line is optional, for determining its absolute value
for k=1:len
for n=1:len
w=exp(-1i*2*pi*(k-1)*(n-1)/len);
a=x(n)*w;
y(k)=y(k)+a;
end
yabs(k)=abs(y(k));%this line is optional
end
yt=fft(x);%this one just for comparation
disp(y)
disp(yabs)%output's absolute value
disp(yt)%fft's output
figure(1)
subplot(3,1,1);
stem(y);
subplot(3,1,2);
stem(yabs);
subplot(3,1,3);
stem(yt);
len=length(x);
y=zeros(1,len);%create an array
yabs=zeros(1,len);%this line is optional, for determining its absolute value
for k=1:len
for n=1:len
w=exp(-1i*2*pi*(k-1)*(n-1)/len);
a=x(n)*w;
y(k)=y(k)+a;
end
yabs(k)=abs(y(k));%this line is optional
end
yt=fft(x);%this one just for comparation
disp(y)
disp(yabs)%output's absolute value
disp(yt)%fft's output
figure(1)
subplot(3,1,1);
stem(y);
subplot(3,1,2);
stem(yabs);
subplot(3,1,3);
stem(yt);
Berikut ini adalah hasil plot signal.