如何在 MATLAB 中计算滤波器的传递函数?

发布于 2024-12-05 09:52:35 字数 1179 浏览 1 评论 0原文

我必须在数字信号处理课程中做一些练习,但遇到一些问题。

我有一个给定的文件(signal.wav 名为信号 x(n) ),其中添加了一些噪声,我要求从中查找一些信息。添加的噪声为η(n) = sin8000πn。所以我正在处理的信号是 s(n) = x(n) + η(n)

为了消除噪声,我应用了阶数 = 2 的低通巴特沃斯滤波器 截止频率 = 2000hz。

我想从过滤器和 H(z) 函数中找到传递函数 H(s) 。我知道我必须应用双线性变换,但我不知道如何使用 MATLAB 来实现。

谁能帮我解决这个问题吗?

这是我的代码

[y, fs, nbits] = wavread('signal.wav');

% Playing the file
disp('-> Playing at the original sample rate...');
sound(y, fs);

fprintf('------------------------------------------\n');
% Sampling frequency
fprintf('-> Sample frequency is:      %f.\n', fs);

% Print the min and max values of the audio data.
fprintf('-> The maximum data value is %f.\n', max(y));
fprintf('-> The minimum data value is %f.\n', min(y));
fprintf('------------------------------------------\n');

order = 2;
sampling_freq = fs;
cut_off_freq = 2000;

[butter_a, butter_b] = butter(order,cut_off_freq/(sampling_freq/2));
%[butter_a, butter_b] = butter(order,cut_off_freq/(sampling_freq));

subplot(211), plot(y);
subplot(212), plot(filter(butter_a,butter_b,y));

sound(filter(butter_a,butter_b,y),fs);

I have to do some exercises in a Digital Signal Processing course and I have some problems.

I have a given file (signal.wav name the signal x(n) ) with some noise added and iIam asked to find some information from it. The noise added is η(n) = sin8000πn. So the signal I am processing is s(n) = x(n) + η(n)

In order to remove the noise, I apply a low-pass butterworth filter with order = 2 and cutoff frequency = 2000hz.

I want to find the transfer function H(s) from the filter and the H(z) function. Well I know that I have to apply bilinear transformation but iIdont know how to do it with MATLAB.

Can anyone help me solve this?

Here is my code

[y, fs, nbits] = wavread('signal.wav');

% Playing the file
disp('-> Playing at the original sample rate...');
sound(y, fs);

fprintf('------------------------------------------\n');
% Sampling frequency
fprintf('-> Sample frequency is:      %f.\n', fs);

% Print the min and max values of the audio data.
fprintf('-> The maximum data value is %f.\n', max(y));
fprintf('-> The minimum data value is %f.\n', min(y));
fprintf('------------------------------------------\n');

order = 2;
sampling_freq = fs;
cut_off_freq = 2000;

[butter_a, butter_b] = butter(order,cut_off_freq/(sampling_freq/2));
%[butter_a, butter_b] = butter(order,cut_off_freq/(sampling_freq));

subplot(211), plot(y);
subplot(212), plot(filter(butter_a,butter_b,y));

sound(filter(butter_a,butter_b,y),fs);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你丑哭了我 2024-12-12 09:52:35

您应该使用 freqs 来计算模拟滤波器的频率响应/传递函数(即H(s))。因此,在本例中,类似:

freqs(butter_b,butter_a,200);

将绘制滤波器在 200 个频率点处的频率和相位响应。您还可以提供应计算的点向量(请参阅链接的文档)。


对于数字滤波器的传递函数(即 H(z)),请使用 freqz.因此,您的语法将类似于:

freqz(butter_b,butter_a,[],fs)

它将再次像以前一样绘制频率和相位响应。再次强调,请确保您阅读链接的文档以正确理解和使用它。

You should use freqs to calculate the frequency response/transfer function of your analog filter (i.e., H(s)). So in this case, something like:

freqs(butter_b,butter_a,200);

will plot the frequency and phase response for the filter at 200 frequency points. You can also provide a vector of points where it should be calculated (see the linked doc).


For the transfer function of the digital filter (i.e., H(z)), use freqz. So your syntax would be something like:

freqz(butter_b,butter_a,[],fs)

which will again plot the frequency and phase responses as before. Again, make sure you read the linked documentation to understand and use it correctly.

锦上情书 2024-12-12 09:52:35

由于您知道信号中不需要的分量的频率,因此您只需估计相位和幅度,然后在时域中从信号中减去添加的噪声分量即可得到解决方案。

有多种方法可以估计正弦的相位和幅度。我建议你尝试 Goertzel 算法。

Since you know the frequency of the unwanted component of the signal you need only to estimate the phase and amplitude and then subtract the added noise component from your signal in the time domain to get the solution.

There are many ways of estimating the phase and amplitude of a sine. I suggest you try the Goertzel algorithm for that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文