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.

カテゴリ

Help Center および File ExchangePulsed Waveforms についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by