Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Filter of sin component of sound signal

2 ビュー (過去 30 日間)
Even Wee
Even Wee 2015 年 4 月 18 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hey
This is a project that i am working on, there we are suppose to filter out a sin-component from a small sound signal.
I have the signal "x" already, this "x" contains the sound signal og the energy-spectral-density.
And I have done all the calculations for the filter and signal, and ended up with this differential equation:
y = 2*a*cos(W_s)*y(n-1) - a.^2*y(n-2) - b0*x(n) - b0*2*cos(W_s)*x(n-1) + b0*x(n-2);
So my next step is to get this signal y(n) and check and se if the sin-component is gone. I know that I should be loop like this:
for n = 3:length(x)
y(n) = 2*a*cos(W_s)*y(n-1) - a.^2*y(n-2) - b0*x(n) - b0*2*cos(W_s)*x(n-1) + b0*x(n-2);
end
But i am getting this error: Attempted to access y(2); index out of bounds because numel(y)=1.

回答 (1 件)

Youssef  Khmou
Youssef Khmou 2015 年 4 月 18 日
編集済み: Youssef Khmou 2015 年 4 月 18 日
Concerning the equation of y, can you explain its origin. As for the error, initial condition must be set :
y=zeros(size(x));
y(1)=x(1);
y(2)=x(2);
% for loop
  2 件のコメント
Even Wee
Even Wee 2015 年 4 月 18 日
Sorry, i have the y(n). It is an array of data like x(n), that contains the sound signal with the sin-component that need to be filtered.
So the differential equation is the differential-equation of the filter. And it should be causal, therefore I need to begin on n = 3.
Even Wee
Even Wee 2015 年 4 月 18 日
編集済み: Even Wee 2015 年 4 月 18 日
Okay.. now i got it to work, and I manage to also filter the sin-component. It was a sign error in my differential-equation, it should be like this
y = 2*a*cos(W_s)*y(n-1) - a.^2*y(n-2) + b0*x(n) - b0*2*cos(W_s)*x(n-1) + b0*x(n-2);
And i think "y" was not initialized when i got this error: "Attempted to access y(2); index out of bounds because numel(y)=1."
But now it works as it should :)
Thank you.

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by