%_______________________________________________________________________  
% PLOTLOG.M          Matlab script to plot ADSP-21160 FFT results
%
% 21-APR-99, Richard Grafton, Analog Devices DSP Div. 
%_______________________________________________________________________
clear;

load inreal1.dat;
load inreal2.dat;
load outreal.dat;
load outimag.dat;

inreal1=inreal1';
inreal2=inreal2';
outreal=outreal';
outimag=outimag';

n=input('Enter length of FFT > ');
y=(1:n/2);

a=[inreal1 inreal2];
b=abs(fft(a));
mag=b(1:n/2);
mag_160=sqrt((outreal.*outreal)+(outimag.*outimag));

log_mag=20*log10(mag);
log_mag_160=20*log10(mag_160);

plot(y,log_mag,'r',y,log_mag_160,'g')
grid
title('Log Magnitude Comparison, MATLAB in red, 21160 in green')
pause

plot(y,mag,'r',y,mag_160,'g')
grid
title('Magnitude Comparison, MATLAB in red, 21160 in green')
pause

plot(y,(mag-mag_160))
grid
title('Error in Magnitude')
pause

b=real(fft(a));
c=b(1:n/2);

plot(y,c,'r',y,outreal,'g')
grid
title('Real Part Comparison, MATLAB in red, 21160 in green')
pause

plot(y,(c-outreal))
grid
title('Error in Real')
pause

b=imag(fft(a));
c=b(1:n/2);

plot(y,c,'r',y,outimag,'g')
grid
title('Imaginary Part Comparison, MATLAB in red, 21160 in green')
pause
plot(y,(c-outimag))
grid
title('Error in Imaginary')
pause
