% Algorithm for Calculating DFT and IDFT using Fixed and Floating Point Technique
clcclear all
close all
N = 32;
M = 16;
x = 0.4 * [ones(1,M),zeros(1,(N-M))];
Q15 = 2^15;
x_fix = fix(Q15 *x);
X = dft(x,N);
xc = idft(X,N);
stem(real(xc));
%Generate input values for fixed point
fid = fopen('input32_DFT_IDFT_fixed.h','w');
fprintf (fid,'#ifndef\t_INPUT_FIXED_H\n');
fprintf (fid,'#define\t_INPUT_FIXED_H\n');
fprintf (fid,'#define\tSIZE\t%d\n',length(x_fix));
fprintf (fid,'int\tx_fix[SIZE]\t=\t{');
fprintf (fid,'%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,\n',x_fix);
fseek (fid,-1,0);fprintf (fid,'};\n');
fprintf (fid,'#endif\n');
fclose (fid);
%it will generate input file with coefficent of input signal..
clcclear all
close all
N = 32;
M = 16;
x = 0.4 * [ones(1,M),zeros(1,(N-M))];
Q15 = 2^15;
x_fix = fix(Q15 *x);
X = dft(x,N);
xc = idft(X,N);
stem(real(xc));
%Generate input values for fixed point
fid = fopen('input32_DFT_IDFT_fixed.h','w');
fprintf (fid,'#ifndef\t_INPUT_FIXED_H\n');
fprintf (fid,'#define\t_INPUT_FIXED_H\n');
fprintf (fid,'#define\tSIZE\t%d\n',length(x_fix));
fprintf (fid,'int\tx_fix[SIZE]\t=\t{');
fprintf (fid,'%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,\n',x_fix);
fseek (fid,-1,0);fprintf (fid,'};\n');
fprintf (fid,'#endif\n');
fclose (fid);
%it will generate input file with coefficent of input signal..
No comments:
Post a Comment