Assignment “Digital Signal Processing” gives a certain set of digital signals. In addition to the target signal, the signal is also mixed with strong noise, but the frequency of the noise and the target signal does not overlap. It is required to use the knowledge learned this semester to analyze the signal. at

“Digital Signal Processing” Big Assignment

Table of contents

1. Question analysis… 2

1.1 HWDATA.MAT file… 2

1.2 Programming ideas… 2

1.3 Principle of FFT algorithm… 2

1.4 Butterworth filter design… 3

2. System block diagram:… 4

3. Code implementation and running results… 4

3.1 Import data… 4

3.2 Draw the original signal time domain waveform… 4

3.3 Draw the frequency domain waveform of the original signal… 5

3.4 Design Butterworth bandpass filter… 6

3.5 Draw the time domain waveform of the target signal… 6

3.5 Draw the frequency domain waveform of the target signal… 7

4. Summary… 7

Program source code:

Create a .m file and copy the following code into the .m file to run it in matlab

load('HWDATA.mat');
%After importing HWDATA.mat, the generated variable is named s1. For convenience, s1 is renamed to HW.
HW=s1;
clear s1;

fs = 500; % sampling frequency is 500Hz
t = (0:length(HW)-1)/fs; % generate time series

figure;
subplot(4,1,1);
plot(t, real(HW));
ylabel('magnitude');
xlabel('time(s)');
title('original signal');

N = length(HW); % number of sampling points
Y = fft(HW); % perform Fourier transform
f = (0:N-1)*(fs/N); % Calculate the frequency axis
P = abs(Y/N); % Calculate the power spectrum

%figure;
subplot(4,1,2);
plot(f, P);
xlim([0, fs/2]);
ylabel('power');
xlabel('Frequency (Hz)');
%title('original signal spectrum');

% Design Butterworth filter

Low = 94; % cutoff frequency lower limit
High = 96; % upper limit of cutoff frequency
order = 4; % order is 4

% Calculate filter coefficients
[b,a] = butter(order, [2*Low/fs, 2*High/fs], 'bandpass');

% Filter the signal
HW_filtered = filtfilt(b, a, HW);

% Plot the filtered signal and spectrum
subplot(4,1,3);
plot(t,real(HW_filtered));
ylabel('magnitude');
xlabel('time(s)');
title('Filtered signal');

subplot(4,1,4);
NFFT = 2^nextpow2(length(HW_filtered));
Y = fft(HW_filtered, NFFT)/length(HW_filtered);
f = fs/2*linspace(0,1,NFFT/2 + 1);
plot(f,2*abs(Y(1:NFFT/2 + 1)));
xlim([90 100]);
ylabel('power');
xlabel('Frequency (Hz)');

1. Question analysis

It is known that a certain set of digital signals (see the HWDATA.mat file in the large homework data compression package) is mixed with strong noise in addition to the target signal, but the frequency of the noise and the target signal does not overlap. It is required to use the data already used this semester. The signal is processed using the learned knowledge and the spectrum diagram of the noise-free target signal is obtained. (20 points)

1.1 HWDATA.MAT file

The data in the HWDATA.MAT file is a time domain signal composed of 500 sampling points.

1.2 Programming Ideas

Because the frequencies of the target signal and the noise signal do not overlap, you can determine the frequency of the target signal by observing the frequency domain waveform of the original signal, and then design a qualified filter to process the original signal, and you can get the target signal.

1.3 Principle of FFT algorithm

The change of signal from time domain to frequency domain can use FFT algorithm. FFT is an efficient algorithm for DFT, called fast Fourier transform. Fourier transform is one of the most basic methods in time domain to frequency domain transform analysis. The FFT algorithm can be divided into time-based extraction algorithm and frequency-based extraction algorithm.

For each K value of X(K), DFT requires 4N real number multiplications and (4N-2) additions. For N k values, a total of N Add up. FFT changes the calculation path and reduces its computational complexity. FFT takes advantage of the periodicity and symmetry in DFT to turn the calculation of the entire DFT into a series of iterative operations, which can greatly improve the calculation process and amount of calculations.

FFT is divided into time extraction and frequency extraction. The most commonly used time domain extraction method is to continuously change long sequences into short sequences according to odd and even numbers. As a result, the input sequence is in reverse order and the output sequence is in sequential order.

For time domain extraction, assume an N-point sequence x(n), group x(n) by odd and even, and decompose an N-point DFT into two N/2-point DFTs. From this, the butterfly knot will be decomposed continuously. The number of times increases exponentially. The butterfly type of each iteration is doubled compared to the previous butterfly generation, and the data point interval is also doubled. At the end of the decomposition, the only operation left in DFT is the operation of the butterfly knot, thus greatly reducing the amount of operation.

Frequency domain extraction is the same as time domain extraction. It also uses odd-even grouping first. The butterfly structure is different from time domain extraction but the number of butterflies is the same. Therefore, the total calculation amount is the same as time domain extraction.

1.4 Butterworth filter design

Filter can use Butterworth filter. The characteristic of the Butterworth filter is that the frequency response curve in the passband is flat to the maximum without fluctuations, while it gradually drops to zero in the stopband. On the Bode plot of the logarithm of amplitude versus angular frequency, starting from a certain boundary angular frequency, the amplitude gradually decreases as the angular frequency increases, tending to negative infinity.

The attenuation rate of an N-order Butterworth filter is 6 N decibels per octave. The Butterworth filter has an amplitude-diagonal frequency curve that decreases monotonically and is the only filter whose amplitude-diagonal frequency curve maintains the same shape regardless of order. The higher the filter order, the faster the amplitude attenuation in the stop band. The order of Butterworth filter in this programming is 4.

2. System block diagram:

Figure 2.1 System block diagram

3. Code implementation and running results

3.1 Import data

Import the HWDDATE.M file and rename the imported variable s1 to HW for subsequent use.

3.2 Draw the original signal time domain waveform

In order to facilitate the observation of the image, the Plot window is divided into four parts 4×1.

Run the program to get the waveform shown in Figure 3.1.

Figure 3.1 Time domain waveform of original signal

At this time, the noise and the target signal cannot be distinguished from the time domain waveform alone, so the signal needs to be further processed.

3.3 Draw the frequency domain waveform of the original signal

First perform FFT transformation on the original signal. Then recalculate the coordinate data.

The frequency domain waveform is then plotted.

Run the program to get the waveform shown in Figure 3.1.

Figure 3.2 Draws the frequency domain waveform of the original signal

After observation, the target signal is the signal from 94HZ to 96HZ.

3.4 Design Butterworth bandpass filter

First design the Butterworth bandpass filter, calculate the parameters required to design the filter through the butter function, and then use the corresponding parameters to design the Butterworth filter through the filtfilt function. As shown in Figure 3.2, the target signal is a signal from 94HZ to 96HZ, so the designed filter order is 4, and the filter frequency is 94HZ to 96HZ.

3.5 Draw the time domain waveform of the target signal

First filter the original signal, and then draw the time domain waveform of the target signal

The drawn image is shown in Figure 3.3

Figure 3.3 Time domain waveform of target signal

After observation, the target signal is normal.

3.5 Draw the frequency domain waveform of the target signal

First perform FFT transformation on the target signal, and then draw the frequency domain waveform of the target signal.

fft is still used here. The drawn image is shown in Figure 3.4

Figure 3.4 Frequency domain waveform of target signal

4. Summary

The code draws a total of four images, and the running results are as follows:

Figure 4.1 Program running results

For this program design, the most critical thing is to draw the frequency domain waveform and observe the frequency of the target signal. For filter design, there are many methods on MATLAB that can be used to design filters, such as filtfilt () function, butter () function, designfilt () function, etc. Each function has its own usage and parameters, which vary according to the parameters. to design different filters. However, it is inconvenient to write these methods directly. We can borrow tools on MATLAB to design filters, which will not be described here. The filter I designed uses the filtfilt () function. First, I need to use the butter () function to calculate the filter parameters, and then use the filter parameters calculated by the butter () function to design the filter through the filtfilt () function. You can get the target signal.