How do I plot a filtered wav file?

2 次查看(过去 30 天)
James Andrew
James Andrew 2018-4-10
评论: Jan 2023-3-1
I have a wav file and I know how to plot that. But then I was given a series like y[n]=x[n]-x[n-5]. I don't want to type the real one b/c I want to do this on my own.
I just would to know how to implement this kind of filter to matlab. Like how do I type y[n]=x[n]-x[n-5] to get an output plot?
  1 个评论
Jan
Jan 2023-3-1
I'm not sure, what the question is. What does "type the real one b/c" mean? What do you want to implement by your own? What have you tried so far and which problems occur?
Do you want to implement the filter using the command filter, or do you prefer a loop? What exactly does "get an output plot" mean?

请先登录,再进行评论。

回答(1 个)

Sufiyan
Sufiyan 2023-3-1
Hello,
You can refer to the code below to get an output plot. In the code shown below, coefficients of output y are a=1(y[n]) and coefficients of x are (x[n], x[n-5]) =>(1,-1). Other coefficients are replaced with zeros as there are no other terms of x (x[n-1],x[n-2]…x[n-4])in the equation.
N = 1000; %no of samples
x = randn(N, 1);
b = [1 0 0 0 0 -1];% x coefficients
a = 1; %y coefficients
y = filter(b, a, x);
n = 1:N;
figure;
plot(n, x, 'b', n, y, 'r');
legend('Input', 'Output');
xlabel('Sample index');
ylabel('Amplitude');
you can refer to filter in the documentation.

Community Treasure Hunt

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

Start Hunting!

Translated by