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
3 次查看(过去 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
0 个评论
采纳的回答
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 个)
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 个评论
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 Center 和 File Exchange 中查找有关 Signal Generation, Manipulation, and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!