Clear Filters
Clear Filters

How do I plot a filtered wav file?

2 views (last 30 days)
James Andrew
James Andrew on 10 Apr 2018
Commented: Jan on 1 Mar 2023
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 Comment
Jan
Jan on 1 Mar 2023
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?

Sign in to comment.

Answers (1)

Sufiyan
Sufiyan on 1 Mar 2023
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!