필터 지우기
필터 지우기

i want to find and hear the frequency responce of a .wav file using following equation y(n)=y(n-1​)-0.9*y(n-​2)+x(n)+x(​n-1) but still its giving error and sound after applying freq responce is not audible.my code is following

조회 수: 1 (최근 30일)
PathOriginal = fullfile('C:\Users\Desktop\assigmnt', 'Voice 002.wav');
[y, Fs, n] = wavread(PathOriginal);
b=[1 1];
a=[1 -1 0.9];
y(n)-y(n-1)+0.9*y(n-2)=x(n)+ x(n-1);
[H,w]=freqz(b,a,n,Fs);
player=audioplayer(y, Fs);
play(player);
player2=audioplayer(H,w, Fs);
play(player2);
what change should i have to applied for desired output responce? help please

채택된 답변

Dinesh Iyer
Dinesh Iyer 2015년 7월 23일
Hi Lione,
It would be good if you can post the error that you are getting. From a quick glance, the second call to audioplayer is incorrect.
audioplayer(H, w, Fs)
will assume w is the sample rate and Fs is the bits per sample. That could be the cause for the error.
Dinesh
  댓글 수: 1
lione felus
lione felus 2015년 7월 24일
편집: lione felus 2015년 7월 24일
thanks dinesh .yes it was error as well but the main error is due to the equation please help me to figure it out .following is the code and error
PathOriginal = fullfile('C:\Users\Desktop\assigmnt', 'Voice 002.wav'); [y, Fs, n] = wavread(PathOriginal);
b=[1 1]; a=[1 -1 0.9];
y(n)= y(n-1)-0.9*y(n-2)+x(n)+x(n-1) [H,w]=freqz(b,a,n,Fs) player=audioplayer(y, Fs) play(player)
player2=audioplayer(H, w, Fs) play(player2)
error : ??? Error: File: q2.m Line: 7 Column: 12
Unexpected MATLAB operator.
this error appears in equation's line .

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2015년 7월 23일
Your line
y(n)-y(n-1)+0.9*y(n-2)=x(n)+ x(n-1);
is not valid syntax. The left hand side of an assignment needs to be a reference to a location, not an expression. The line does not match your title of the Question, where you have
y(n)=y(n-1)-0.9*y(n-2)+x(n)+x(n-1)
Remember, MATLAB input is commands not algebraic expressions.
You could probably write it as a filter of some kind, but for now write it as a for loop:
x = y;
Y = zeros(size(x));
Y(1:2,:) = randn(2,size(x,2));
for n = 3 : size(x,2)
Y(n,:) = Y(n-1,:) + 0.9 * Y(n-2,:) + x(n,:) + x(n-1,:);
end
If you look at this carefully you will see that x(1,:) is never used and that Y has some random initializations and so will produce different results every run. These things happen when you do not define your boundary conditions.
  댓글 수: 4
lione felus
lione felus 2015년 7월 24일
편집: lione felus 2015년 7월 24일
here is the m file of my code walter .i didnt put multiple commands in a line in m file here may be this happen due to copy paste issue ..can you please look at it n suggest what should i do to resolve this error.
Walter Roberson
Walter Roberson 2015년 7월 24일
The line there is stored as
y(n)= y(n-1?)-0.9*y(n-?2)+x(?n-1)+x(n)
where the '?' is literally the character '?'.
It appears that at some point you put a non-ASCII character in those positions.
Delete the line and re-type it.

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

카테고리

Help CenterFile Exchange에서 Measurements and Spatial Audio에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by