0% found this document useful (0 votes)
6 views6 pages

New Algorithm With Translation

The document outlines a MATLAB script for signal processing using wavelet decomposition. It loads a dataset, performs multi-level decomposition using Haar and Daubechies wavelets, and reconstructs low and high frequency components for visualization. The script generates multiple plots to display the original and reconstructed signals across different layers.

Uploaded by

nayem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views6 pages

New Algorithm With Translation

The document outlines a MATLAB script for signal processing using wavelet decomposition. It loads a dataset, performs multi-level decomposition using Haar and Daubechies wavelets, and reconstructs low and high frequency components for visualization. The script generates multiple plots to display the original and reconstructed signals across different layers.

Uploaded by

nayem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

clear all;

clc;

close all;

load wav2.mat %Open the wav2.mat data set y3

x=0:0.01:9.99; % Takes x as a geometric sequence between 0 and 9.99 as the time

N=6; % Represents five levels

f=zeros(6,1000); %f represents the low frequency band, divided into five layers. Zeros represents a
matrix of all zeros, with 5 rows and 1000 columns

h=zeros(6,1000); %h represents the high frequency band divided into five layers

[c,l]=wavedec(y3,N,'haar');

% Decompose the signal with one-dimensional N-scale using y3, and return the wavelet
coefficients of each layer, haar represents the Haar wavelet, which is the selected wavelet basis function

% Return value on the left: C is each coefficient after wavelet decomposition, L is the number of
corresponding wavelet coefficients;

for i=1:6 %i takes 1 to 5 respectively to do the following loop operation

f(i,:)=wrcoef('a',c,l,'haar',i); % All elements of the i-th row of matrix f

h(i,:)=wrcoef('d',c,l,'haar',i); %wrcoef is a one-dimensional multi-level decomposition and


reconstruction signal function, using the c and l values obtained just after decomposition to reconstruct
the original signal, that is, the return value on the left;

% 'a' or'd' stands for "low frequency approximation" or "high frequency details", C and L are the
values obtained just after decomposition, and "haar" means consistent with the wavelet basis function
during decomposition, and the last number i is where the part is located series;

end

figure(1) %Create figure 1;;

subplot(3,2,1); % Divide the current figure into a 3×2 grid, and create an axis at the first position.
Number the sub-picture position by line number.

% The first subgraph is the first column of the first row, the second subgraph is the second
column of the first row, and so on.

% If the specified location already has an axes, this command will set the axes as the
current axes。

plot(x,y3,'r'); % In the sub-picture window, draw a function image where x is the abscissa, y3 is the
ordinate, and ‘r’ represents the use of a red line

title('原始信号'); % The sub-picture title is ‘Original Signal’


xlabel('时间 s'); %x axis is marked as ‘time s’

subplot(3,2,3); % Divide the current figure into a 3×2 grid, and create an axis at the third position。

plot(x,f(5,:)); %x is used as the abscissa, and the low frequency band of the reconstructed signal of the
5th layer is used as the ordinate, and the graph is drawn;

xlabel('时间 s'); %x axis is marked as ‘time s’

ylabel('a5'); %y axis is labeled ‘a5’

grid on; % Show grid lines (grid off means hidden grid lines)

subplot(3,2,4); % Divide the current figure into a 3×2 grid, and create an axis at the fourth position.

plot(x,h(5,:)); %x is used as the abscissa, and the high frequency band of the reconstructed signal of
the 5th layer is used as the ordinate, and the graph is drawn;

xlabel('时间 s'); %x axis is marked as ‘time s’

ylabel('d5'); %y axis is labeled ‘d5’

grid on; % Show grid lines

subplot(3,2,5); % Divide the current figure into a 3×2 grid, and create an axis at the fifth position。

plot(x,f(4,:)); %x is the abscissa, the low frequency band of the reconstructed signal of the 5th layer is
the ordinate, and the picture is drawn; (Originally it was f5, I changed it to f4 了)

xlabel('时间 s'); %x axis is marked as ‘time s’

ylabel('a4'); %y axis is marked as ‘a4’

grid on; % Show grid lines

subplot(3,2,6);%将当前图窗划分为 3×2 网格,并在第 6 个位置创建坐标区。

plot(x,h(4,:)); %x 做横坐标,第 4 层的重构信号的高频段做纵坐标,画图;(本来是 h5,我改成 h4 了)

xlabel('时间 s'); %x 轴标记为‘时间 s’

ylabel('d4'); %y 轴标记为‘d4’

grid on; %显示网格线

figure(2) %创建图窗 2;

subplot(3,2,1); %将当前图窗划分为 3×2 网格,并在第 1 个位置创建坐标区。


plot(x,f(3,:)); %x 做横坐标,第 3 层的重构信号的低频段做纵坐标,画图;

xlabel('时间 s'); %x 轴标记为‘时间 s’

ylabel('a3'); %y 轴标记为‘a3’

grid on; %显示网格线

subplot(3,2,2); %将当前图窗划分为 3×2 网格,并在第 2 个位置创建坐标区。

plot(x,h(3,:)); %x 做横坐标,第 3 层的重构信号的高频段做纵坐标,画图;

xlabel('时间 s'); %x 轴标记为‘时间 s’

ALGOIRTHM
clear all;
clc;
close all;
StepData = xlsread('C:\Users\debuf\Desktop\y1.xlsx');
ys=StepData (1,:);
Ls=length(ys);
ys_g= resample(ys, 1000, Ls);
figure(1)
subplot(3,1,1);
plot(ys_g,'r')
title('原始信号');% The sub-picture is titled ‘Original Signal’
xlabel('时间 s'); %x The axis is labeled ‘time s’

N=5; % Represents five levels


f=zeros(5,1000); %f represents the low frequency band, divided into five layers.
Zeros represents the generation of a matrix of all 0s, with 5 rows and 1000
columns
h=zeros(5,1000); %h represents the high frequency band divided into five layers
[c,l]=wavedec(ys_g,N,'db3');

for i=1:5 %i takes 1 to 6 respectively to do the following loop operation


f(i,:)=wrcoef('a',c,l,'db3',i); % All elements in the i-th row of matrix f,'a' or'd'
stand for "low frequency approximation" or "high frequency details"
h(i,:)=wrcoef('d',c,l,'db3',i); %wrcoef is a one-dimensional multi-level
decomposition and reconstruction signal function, using the c and l values just
decomposed to reconstruct the original signal, that is, the return value on the
left;
%'a' or'd' stands for "low frequency approximation" or "high frequency details", C
and L are the values obtained just after decomposition, and "haar" means that
they are consistent with the wavelet basis function during decomposition, and the
last number i is where the part is The number of levels;
end

x=0:0.01:9.99;
subplot(3,2,3); % Divide the current figure into a 3×2 grid, and create an axis at
the third position。
plot(x,f(5,:)); %x is the abscissa, and the low frequency band of the reconstructed
signal of the 5th layer is the ordinate, and the graph is drawn;
xlabel('时间 s'); %x axis is marked as ‘time s’
ylabel('a5'); %y axis is labeled ‘a5’
grid on; % Show grid lines (grid off means hidden grid lines)
subplot(3,2,4); % Divide the current figure into a 3×2 grid, and create an axis at
the fourth position。
plot(x,h(5,:)); %x is the abscissa, and the high frequency band of the
reconstructed signal of the 5th layer is the ordinate, and draw the picture;
xlabel('时间 s'); %x axis is marked as ‘time s’
ylabel('d5'); %y axis is labeled ‘d5’
grid on; % Show grid lines

subplot(3,2,5); % Divide the current figure into a 3×2 grid, and create an axis at
the fifth position.
plot(x,f(4,:)); %x is the abscissa, the low frequency band of the reconstructed
signal of the 5th layer is the ordinate, and the picture is drawn; (it was originally
f5, I changed it to f4)
xlabel('时间 s'); %x axis is marked as ‘time s’
ylabel('a4'); %y axis is labeled ‘a4’
grid on; % Show grid lines

subplot(3,2,6); % Divide the current figure into a 3×2 grid, and create an axis at
the sixth position.
plot(x,h(4,:)); %x is the abscissa, the high frequency band of the reconstructed
signal of the 4th layer is the ordinate, and the picture is drawn; (it was originally
h5, I changed it to h4)
xlabel('时间 s'); %x axis is marked as ‘time s’
ylabel('d4'); %y axis is labeled ‘d4’
grid on;

figure(2) % Create figure 2;


subplot(3,2,1); % Divide the current figure into a 3×2 grid, and create an axis at
the first position。
plot(x,f(3,:)); %x is used as the abscissa, and the low frequency band of the
reconstructed signal of the third layer is used as the ordinate, and the graph is
drawn;
xlabel('时间 s'); %x axis is marked as ‘time s’
ylabel('a3'); %y axis is labeled ‘a3’
grid on; % Show grid lines

subplot(3,2,2); % Divide the current figure into a 3×2 grid, and create an axis at
the second position。
plot(x,h(3,:)); %x is the abscissa, and the high frequency band of the
reconstructed signal of the 3rd layer is the ordinate, and draw the picture;
xlabel('时间 s'); %x axis is marked as ‘time s’
ylabel('d3'); %y axis is labeled ‘d3’
grid on; % Show grid lines

subplot(3,2,3); % Divide the current figure into a 3×2 grid, and create an axis at
the third position。
plot(x,f(2,:)); %x is used as the abscissa, and the low frequency band of the
reconstructed signal of the second layer is used as the ordinate, and the graph is
drawn
;xlabel('时间 s'); %x axis is marked as ‘time s’
ylabel('a2'); %y axis is marked as ‘a2’
grid on; % Show grid lines

You might also like