%%%%%%%%%%%%%%%%%%%%% %% Time-Data generation %% %%%%%%%%%%%%%%%%%%%%% clear all TIME=5; N=128; t=linspace(0,TIME,N); y=2*sin(10*t)-2*sin(25*t+pi/4)+2*cos(40*t+pi/8); [FileID]=fopen('data.dat','wt+'); fprintf(FileID,'%f\n',y); fclose('all'); % Ploting the results kk=0:N-1; figure stem(kk,y,'fill') grid on axis tight title('\bf< Gendrated time signal >','fontsize',12) %%%%%%%%%%%%%%%%%%%%% %% Time-Data read %% %%%%%%%%%%%%%%%%%%%%% clear all; [FileID]=fopen('data.dat','r'); [x count]= fscanf(FileID,'%f \n'); fclose('all'); %%%%%%%%%%%%%%%%%%%%% %% DIT-FFT calculation %% %%%%%%%%%%%%%%%%%%%%% nu=log2(length(x)); N=2^nu; NM=N-1; %% Rearrange data by bit reversing jj=1; for ii=2:NM k=N/2; while(k','fontsize',12) subplot(222) stem(kk,X_imag,'fill') grid on axis tight title('\bf< Imaginary >','fontsize',12) subplot(223) stem(kk,X_mag,'fill') grid on axis tight title('\bf< Magnitude >','fontsize',12) subplot(224) stem(kk,X_phase,'fill') grid on axis tight title('\bf< Phase >','fontsize',12) %%%%%%%%%%%%%%%%%%%%% %% Frequency-Data write %% %%%%%%%%%%%%%%%%%%%%% [FileID]=fopen('fft_data.dat','wt+'); for i=1:N fprintf(FileID,'%f %f\n',X_real(i),X_imag(i)); end fclose('all'); %%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%% %% Frequency-Data read %% %%%%%%%%%%%%%%%%%%%%% clear all; [FileID]=fopen('fft_data.dat','r'); [F count]= fscanf(FileID,'%f\n'); fclose('all'); %%%%%%%%%%%%%%%%%%% %% DIT-IFFT calculation %% %%%%%%%%%%%%%%%%%%% N=128; Freq=reshape(F,2,N)'; x=Freq(:,1)+i*Freq(:,2); nu=log2(length(x)); NM=N-1; kk=0:NM; %% Rearrange data by bit reversing jj=1; for ii=2:NM k=N/2; while(k','fontsize',12)