disp(' ') disp(' inverseFFT.m ') disp(' ver 1.2 January 19, 2012 ') disp(' by Tom Irvine Email: tomirvine@aol.com ') disp(' ') disp(' This program calculates the inverse of a double-sided complex FFT'); disp(' ') disp(' The FFT must have 2^N points, where N is an integer. '); disp(' ') % clear CFFT; clear Y; clear YR; clear YI; clear TT; clear ccc; % disp(' '); disp(' Select input format: '); disp(' 1= Two columns: freq(Hz) complex '); disp(' 2=Three columns: freq(Hz) real imag '); % ifor=input(' '); % disp(' ') disp(' Select file input method '); disp(' 1=external ASCII file '); disp(' 2=file preloaded into Matlab '); file_choice = input(''); % if(file_choice==1) disp(' Enter the input filename '); filename = input(' ','s'); fid = fopen(filename,'r'); if(ifor==1) CFFT = fscanf(fid,'%g %g',[2 inf]); else CFFT = fscanf(fid,'%g %g %g',[3 inf]); end CFFT=CFFT'; else CFFT = input(' Enter the matrix name: '); end % N=length(CFFT(:,1)); % out3 = sprintf('\n Number of Samples = %d \n',N); disp(out3); % iflag=0; % for(i=1:18) if( 2^i == N ) iflag=1; break; end end % if( iflag==0) disp(' Error: illegal number of samples '); disp(' '); end % if(ifor==1) ccc=CFFT(:,2); else ccc=complex(CFFT(:,2),CFFT(:,3)); end % Y = ifft(ccc,N); % resume here % disp(' Plot the real inverse FFT ') choice = input(' 1=yes 2=no '); % dt=1./max(CFFT(:,1)); % TT = linspace(0.,N*dt,N); TT=TT'; % if(choice == 1) figure(1); YR=real(Y); plot(TT,YR) xlabel(' Time (sec)'); ylabel(' Amplitude'); end % disp(' Plot the imaginary inverse FFT ') choice = input(' 1=yes 2=no '); % if(choice == 1) figure(1); YI=imag(Y); plot(TT,YI) xlabel(' Time (sec)'); ylabel(' Amplitude'); end