Fast Fourier Inverse Optimization?

3 views (last 30 days)
denis bertin
denis bertin on 25 Sep 2017
Edited: Walter Roberson on 25 Sep 2017
Hi everyone,
I want to optimized this function (Inverse fourrier), make it more faster.
Please can you help me?
Many thank.
If you want a *.mat file to test,please ask me. I don't know use inverse fourrier transform. Many thank's
function datineltempo_ciclico
%Questa funzione apre i files .mat conteneti la struttura Eurydice e genera tutte le Bscan nel tempo per ogni configurazione di antenna e le salva in formato ascii.
clear all
[FileNameRead,PathNameRead] = uigetfile('*.mat', 'Apertura .mat file', 'MultiSelect', 'on'); % Apro i files
if(char(FileNameRead) ~= 0) %%%Controlla se almeno un file è stato selezionato
FileName = strcat(PathNameRead, FileNameRead);
if(~iscell(FileName)) %%%Verifica della selezione multipla di files
FileName = {FileName}; %%%In caso di selezione singola il nome da stringa viene convertito in cell
end
dx = input('dammi il passo di misura desiderato [m]');
for(u = 1:size(FileName, 2))
Name = char(FileName(u));
if(strcmp(Name(end-2:end),'mat')) %%%Verifica se il file da aprire è un .mat
Dummy = open(Name);
Eurydice = Dummy.Eurydice;
clear Dummy;
fmin = Eurydice.Header.Fstart * 10^6;
fmax = Eurydice.Header.Fstop * 10^6;
posizioni = Eurydice.Position;
szd = size(Eurydice.Data);
Nf = szd(1); %numero di frequenze
NP = szd(2); %numero di punti di misura
datif = zeros(Nf, NP);
datif1 = zeros(Nf, NP);
if(length(szd) == 3)
for(conf = 1:3)
datif(:,:) = Eurydice.Data(:,:,conf);
L = posizioni(end);
% ESTRAZIONI POSIZIONI DI MISURA DIVERSE FRA LORO
posvere(1) = posizioni(1);
datif1 = 0 * datif;
datif1(:,1) = datif(:,1);
nn = 1;
icp = 2; % indice di cumulo parziale
for k=2:NP
if abs(posizioni(k) - posizioni(k - 1)) > 0
nn = nn + 1;
posvere(nn) = posizioni(k);
datif1(:,nn) = datif(:,k);
icp = 2;
else
datif1(:,nn) = ((icp - 1) / icp) * datif1(:,nn) + (1 / icp) * datif(:,k);
icp = icp + 1;
end
end
NPV = length(posvere);
posvere1 = posvere - posvere(1);
datif1 = datif1(:,1:NPV);
L1 = posvere1(end);
% INTERPOLAZIONE PER AVERE MISURE A PASSO FISSO
datif2(:,1) = datif1(:,1);
nn = 2;
NP1 = ceil(L1 / dx);
for(k = 2:NP1)
posatt = dx * (k - 1);
[vmin,ind] = min(abs(posvere1 - posatt));
if(vmin == 0)
datif2(:,nn) = datif1(:,ind);
nn = nn + 1;
else
if(posvere1(ind) > posatt)
v1 = datif1(:,ind - 1);
v2 = datif1(:,ind);
x1 = posvere1(ind - 1);
x2 = posvere1(ind);
datif2(:,nn) = interplin(x1,x2,v1,v2,posatt);
nn = nn + 1;
else
if posatt < L1
v1 = datif1(:,ind);
v2 = datif1(:,ind + 1);
x1 = posvere1(ind);
x2 = posvere1(ind + 1);
datif2(:,nn) = interplin(x1,x2,v1,v2,posatt);
nn = nn + 1;
end
end
end
end
sizedata = size(datif2);
NPF = sizedata(2);
DF = (fmax - fmin) / (Nf - 1); % passo in frequenza
f = linspace(fmin,fmax,Nf);
f = f';
t = linspace(0,0.5/DF,2001);
%NPF
datit = zeros(2001,NPF);
N=length(t);
for(k = 1:NPF)
v = datif2(:,k);
g = zeros(2001,1);
du=f(2)-f(1);
for k1=1:N
integrando=exp(i*2*pi*t(k1)*f).*v;
g(k1)=du*sum(integrando);
end
v1 = g;
v1 = 2 * real(v1);
datit(:,k) = v1;
%k
end
datit = datit';
%%%Salvataggio della matrice datit in un file .txt
Name = char(FileName(u));
if(conf == 1)
save(strcat(Name(1:end-4), '_L.asc'), 'datit', '-ASCII');
elseif(conf == 2)
save(strcat(Name(1:end-4), '_M.asc'), 'datit', '-ASCII');
elseif(conf == 3)
save(strcat(Name(1:end-4), '_H.asc'), 'datit', '-ASCII');
end
end
else
h_warndlg = warndlg('ATTENZIONE: il file selezionato non comprende tutte le tre configurazioni di antenna', 'Aperura .mat file');
uiwait(h_warndlg);
end
else
h_warndlg = warndlg('ATTENZIONE: il file selezionato non ha l''estensione .mat - Non verrà salvato il file .asc', 'Creazione .asc file');
uiwait(h_warndlg);
end
clear datif datif1 datif2 datit posizioni posvere posvere1
fprintf('Sono stati correttamente processati %d files. Attendere....\n', u);
end
else
h_warndlg = warndlg('ATTENZIONE: Nessun file selezionato', 'Aperura .mat file');
uiwait(h_warndlg);
end
fprintf('Tutti i files sono stati correttamente processati.\n');
Please Help me.

Answers (0)

Categories

Find more on Statistics and Machine Learning Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!