1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
clear all
close all
RootDir=['C:\Documents\Datas\'];
%listDir = dir(RootDir)
FileName = '6c47e2';
cd([RootDir,FileName]) ;
rep=[RootDir,FileName] ;
ext = '*.gcf';
chemin = fullfile(rep,ext);
list = dir(chemin);
% lecture en boucle des signaux dans dossiers
for n = 1:numel(list)
[list(n).name,ext(3:end)]
[signal,streamID,sps,ist]=readgcffile([list(n).name]);
signalRaw = signal ;
ind = find(isnan(signal));
signal(ind)=[] ;
taille = numel(signal);
duree = taille/sps ; % sps = sample frequency
temps = linspace(ist,ist+(duree*(1/24/60/60)),taille) ;
%% moyennage du signal = 0
moySignal=mean(signal) ;
signal = signal-moySignal ;
%% apodisation par fenetre de hanning
nH = 3000 ;
pourcentage_echantillon_han = 1 ; % ! en %
[windowHann,SigHann,maxSigx] = HannWinCell(signal,nH,pourcentage_echantillon_han);
signal = SigHann ;
%% spectro
% Compute the ifft of the signal
L = numel(signal)
NFFTbis = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(signal,NFFTbis)/L;
fbis = sps/2*linspace(0,1,NFFTbis/2+1);
% % spectrogramme
nfft = 128 ;
[S,F,T,P] = spectrogram(signal,nfft,[],nfft,sps);
figure ;
subplot(3,1,1);
plot(temps, signal,'b');
hold on
plot(temps,windowHann,'r')
plot(temps,signalRaw,'g')
legend('signal corrected', 'Hanning window','raw signal')
% xlim([temps(1) temps(end)]) ;
title([list(n).name]) ;
datetick('x','HH:MM','keeplimits')
subplot(3,1,2);
surf(T,F,10*log10(P),'edgecolor','none');
axis tight;
view(0,90);
subplot(3,1,3);
plot(fbis,2*abs(Y(1:NFFTbis/2+1)))
clear signal streamID sps ist ;
end |
Partager