time interval between fft1 and fft2
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello to everyone,
In my program I have created two different functions to compute the 1-D and 2-D fft (Fast Fourier Transform) of an array A(4x4).Now, I want to compute the time interval regarding the time difference between the 2 routines.Does anybody knows how it must be done?
Thamks in advance
%%%%%%%%%%%Program%%%%%%%%%%%%%%%%%% % Read & plot & find spectrum of *.dat image function []=Program_3(); clc;echo off;close all; A=[30,31,12, 9, 17,12,25,10, 12, 8,17, 9, 31,12,26,22];
A=double(A);B=A; disp(A); image_depth=31;tones=8;
value =1;
switch value
case 1
B=ampl_fft(A);
case 2
B=ampl_fft2(A);
end;
max_B=max(max(B));min_B=0;B=(B-min_B)*(image_depth/(max_B-min_B));%back to image_depth
disp(round(B));
%==================================================================function [C]=ampl_fft(A) x=size(A,1);y=size(A,2); %/*-------- 2D - FFT ---------*/ %/*---------- do rows first ----------*/ C=A; for i=1:x, for j=1:y, if ( rem((i+j),2) == 1) C(i,j) = -C(i,j); else C(i,j) = C(i,j); end;%if end;%j end;%i
for i=1:x for j=1:y, Cy(j)=C(i,j); end;%j Cy=fft(Cy,y); for j=1:y, C(i,j) = Cy(j); end;%j end;%of i %/*------ do columns next---*/ for j=1:y %for each column for i=1:x Cx(i)=C(i,j); end;%i Cx=fft(Cx,x); %/*----- Compute Log Amplitude -----*/ for i=1:x C(i,j) = round(10.0 * log(1+ abs(Cx(i)) )); end;%i end;%j
%================================================================ function [C]=ampl_fft2(A) x=size(A,1);y=size(A,2);
%/*-------- 2D - FFT ---------*/ for i=1:x; for j=1:y; if ( rem((i+j),2) == 1) A(i,j) = -A(i,j); else A(i,j) =A(i,j); end;%if end;%j end;%i C=fft2(A); C=round(10.0 * log(abs(C)+1)); %==========================================
0 commentaires
Réponse acceptée
Rob Graessle
le 25 Mar 2011
When you say "time difference", do you mean the difference in execution time between the two routines?
tic
B=ampl_fft(A);
time1=toc;
tic
B=ampl_fft2(A);
time2=toc;
timeDifference=time2-time1; % Difference in execution time in seconds
0 commentaires
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Fourier Analysis and Filtering dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!