diff --git a/PARTIE3.m b/PARTIE3.m index 888691cef9c8317ba3736e5309d0c767a666635b..fe6676caadb3aa17d81fa5033937f9dd68f1c3de 100644 --- a/PARTIE3.m +++ b/PARTIE3.m @@ -6,7 +6,7 @@ clear; close all; clc Fe = 44100; % frequence d echantillonnage %% ======================================================================== -%% Q 3.1 — Correlation croisee R yx = R xx * h +%% Q 3.1 — Correlation croisee R R xx * h % ------------------------------------------------------------------------- dur = 0.05; f0 = 1000; t = (0:1/Fe:dur - 1/Fe).'; @@ -36,8 +36,8 @@ title('Q 3.2 Estimation h'); %% ======================================================================== %% Q 3.3 — Choix du meilleur signal d excitation % ------------------------------------------------------------------------- -if exist('signalExcitation.mat','file') - load signalExcitation.mat % attend variables xe1, xe2 +if exist('signal_excitation.mat','file') + load ('signal_excitation.mat') % attend variables xe1, xe2 lag = 1024; Rxe1 = max(abs(xcorr(xe1,lag,'biased'))); Rxe2 = max(abs(xcorr(xe2,lag,'biased'))); @@ -51,19 +51,27 @@ end %% ======================================================================== %% Q 3.4 — Simulation de mesure de piece et estimation de h % ------------------------------------------------------------------------- -if exist('simulePiece','file') && ~isempty(choix) - [tensionMicro, excitation] = simulePiece(choix); +if exist('simule_piece.m','file') && ~isempty(choix) + if strcmp(choix,'xe1') + excitation = xe1; + else + excitation = xe2; + end + tensionMicro = simule_piece(excitation, Fe); + lag = 4000; - hPiece = xcorr(tensionMicro, excitation, lag,'biased'); + % Utilisation sans 'biased' car tensionMicro et excitation sont de tailles différentes + hPiece = xcorr(tensionMicro, excitation, lag); hPiece = hPiece(lag+1:end); figure('Name','Q3-4 h piece'); plot(hPiece); grid on; title('Q 3.4 h mesuree'); else - warning('Fonction simulePiece absente ou signal non choisi — Q 3.4 ignoree'); + warning('Fonction simule_piece absente ou signal non choisi — Q 3.4 ignoree'); hPiece = h; % secours : reponse test excitation = x; % secours : signal test end + %% ======================================================================== %% Q 3.5 — Fonction effectReverb (convolution directe) % -------------------------------------------------------------------------