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