1
votes

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);
2
ITYM transfer function (not "transport function") ? You might also be better off asking this in dsp.stackexchange.com since it's more DSP-related than programming-related.Paul R
Sorry i tried to translate from my native language. I meant transfer function.john_pots

2 Answers

2
votes

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.

0
votes

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.