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 view (last 30 days)
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

Accepted Answer

Dinesh Iyer
Dinesh Iyer on 23 Jul 2015
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 Comment
lione felus
lione felus on 24 Jul 2015
Edited: lione felus on 24 Jul 2015
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 .

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 23 Jul 2015
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 Comments
lione felus
lione felus on 24 Jul 2015
Edited: lione felus on 24 Jul 2015
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 on 24 Jul 2015
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.

Sign in to comment.

Categories

Find more on Measurements and Spatial Audio in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!