Azzera filtri
Azzera filtri

Add together two stem plots

25 visualizzazioni (ultimi 30 giorni)
S
S il 29 Giu 2024 alle 23:12
Commentato: Voss il 15 Lug 2024 alle 20:53
I am trying to add together stem plots. I am getting an error on using + to do this. I am unsure how I am meant to add them together as they work individually. I am trying to take Add1 and Add2 and add them in Total, then take the impulse using yimp and plot that result. Thank you for your time!
%Parameters
fs = 16e3;
t = 0:(1/fs):0.03;
t = t(:); % ensure column vector
numFilts = 32;
filter_number = 10;
range = [50 8000];
gammaFiltBank = gammatoneFilterBank(range,numFilts,fs); % set fs explicity
input_signal = sin(2*pi*100*t) + sin(2*pi*300*t);
output_signal = gammaFiltBank(input_signal);
figure %1
stem(t,output_signal(:,filter_number));
title('Output of Filter', num2str(filter_number))
impulse_input = 0*t;
impulse_input(1) = 1;
reset(gammaFiltBank); % IMPORTANT!
yimp = gammaFiltBank(impulse_input);
%Add together outputs of specific filters
filter_number2=12;
Add1=stem(t,output_signal(:,filter_number));
Add2=stem(t,output_signal(:,filter_number2));
Total=Add1 + Add2;
stem(t,yimp(:,Total))
title('Impulse of', num2str(filter_number), 'plus', num2str(filter_number2))

Risposta accettata

Voss
Voss il 30 Giu 2024 alle 0:36
%Parameters
fs = 16e3;
t = 0:(1/fs):0.03;
t = t(:); % ensure column vector
numFilts = 32;
filter_number = 10;
range = [50 8000];
gammaFiltBank = gammatoneFilterBank(range,numFilts,fs); % set fs explicity
input_signal = sin(2*pi*100*t) + sin(2*pi*300*t);
output_signal = gammaFiltBank(input_signal);
figure %1
stem(t,output_signal(:,filter_number));
title(sprintf('Output of Filter %d',filter_number))
figure
impulse_input = 0*t;
impulse_input(1) = 1;
reset(gammaFiltBank); % IMPORTANT!
yimp = gammaFiltBank(impulse_input);
%Add together outputs of specific filters
filter_number2=12;
Add1=yimp(:,filter_number);
Add2=yimp(:,filter_number2);
Total=Add1 + Add2;
stem(t,Total)
title(sprintf('Impulse of %d plus %d',filter_number,filter_number2))
  2 Commenti
S
S il 15 Lug 2024 alle 17:02
@Voss Thank you! Why am I not able to add them before I do impulse?
Voss
Voss il 15 Lug 2024 alle 20:53
You're welcome! This is adding two impulse responses.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Audio Processing Algorithm Design in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by