Borrar filtros
Borrar filtros

Add together two stem plots

25 visualizaciones (últimos 30 días)
S
S el 29 de Jun. de 2024 a las 23:12
Comentada: Voss el 15 de Jul. de 2024 a las 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))

Respuesta aceptada

Voss
Voss el 30 de Jun. de 2024 a las 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 comentarios
S
S el 15 de Jul. de 2024 a las 17:02
@Voss Thank you! Why am I not able to add them before I do impulse?
Voss
Voss el 15 de Jul. de 2024 a las 20:53
You're welcome! This is adding two impulse responses.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Audio Processing Algorithm Design en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by