%_______________________________________________________________________  
% PLOTLOG.M          Matlab script to plot ADSP-21020 FFT results
%
% 21-MAR-91, Steven Cox, Analog Devices DSP Div. 
%_______________________________________________________________________
len=.5*input('Enter length of real FFT > ');
y=(1:len);
load inreal.mat;
load inimag.mat;
j=sqrt(-1);
incplx=inreal+(inimag*j);
load rdata.mat;
load idata.mat;

gldfft = fft(incplx);
gldfft = gldfft(1:len);

mlb=20*log10(abs(gldfft));
chip=20*log10(sqrt((rdata.*rdata)+(idata.*idata)));
plot(y,mlb,'r',y,chip,'g')
grid
title('Log Magnitude Comparison, 21k in green')
pause

plot(y,abs(gldfft),'r',y,(sqrt((rdata.*rdata)+(idata.*idata))),'g')
grid
title('Magnitude Comparison, 21k in green')
pause

plot(y,sqrt((rdata.*rdata)+(idata.*idata))-abs(gldfft))
grid
title('Absolute Error in Magnitude')
pause
plot(y,(sqrt((rdata.*rdata)+(idata.*idata))-abs(gldfft))/max(abs(gldfft)))
grid
title('Norm Error in Magnitude (Error/max(mag))')
pause

plot(y,real(gldfft),'r',y,rdata,'g')
grid
title('Real Part Comparison, 21k in green')
pause
plot(y,(rdata-real(gldfft)))
grid
title('Absolute Error in Real')
pause
plot(y,(rdata-real(gldfft))/max(abs(gldfft)))
grid
title('Norm Error in Real (Error/max(mag))')
pause

plot(y,imag(gldfft),'r',y,idata,'g')
grid
title('Imaginary Part Comparison, 21k in green')
pause
plot(y,(idata-imag(gldfft)))
grid
title('Absolute Error in Imaginary')
pause
plot(y,(idata-imag(gldfft))/max(abs(gldfft)))
grid
title('Norm Error in Imaginary (Error/max(mag))')
