Skip to content
Snippets Groups Projects
Commit 4da57112 authored by Marc DUBOC's avatar Marc DUBOC
Browse files

Update code matlab

parent 9ea26fb6
No related branches found
No related tags found
No related merge requests found
......@@ -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)
% -------------------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment