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
16 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
lione felus
il 23 Lug 2015
Commentato: Walter Roberson
il 24 Lug 2015
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 Commenti
Risposta accettata
Dinesh Iyer
il 23 Lug 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 Commento
Più risposte (1)
Walter Roberson
il 23 Lug 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 Commenti
Walter Roberson
il 24 Lug 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.
Vedere anche
Categorie
Scopri di più su Digital Filter Design in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!