필터 지우기
필터 지우기

Add together two stem plots

조회 수: 25 (최근 30일)
S
S 2024년 6월 29일 23:12
댓글: Voss 2024년 7월 15일 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))

채택된 답변

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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Audio Processing Algorithm Design에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by