Generate a wavelet function?

24 views (last 30 days)
Jess
Jess on 28 Feb 2014
Commented: Tubi on 22 Mar 2017
I'm relatively fluent in matlab, but wavelets are not something I've ever actually worked with before. I have read the wavelet toolbox manual, but it doesn't provide everything I need in terms of an explanation or instructions.
I need to do the following
1) Create unique wavelet functions for several unique sets of generated data, 1 wavelet for each data set.
2) Multiply each wavelet function by a unique coefficient and do the summation of all of this
3) Perform a least squares regression to generate the coefficients which will allow the summation to most closely approximate a user-defined combination of one or more of the wavelet functions.
%% Pull Data from Excel file & Create Matrices
L2 = xlsread('PS.xlsx','S3','B11:C2011'); % Seperate Original Energy Divisions
L2_E = L2(:,1); % X-Values
L2_C = L2(:,2); % Y-Values
L3 = xlsread('PS.xlsx','S3','G11:H2011'); L3_E = L3(:,1); L3_C = L3(:,2);
L4 = xlsread('PS.xlsx','S3','L11:M2011'); L4_E = L4(:,1); L4_C = L4(:,2);
%% Apply Wavelets
% Approximation(A): High-Scale, Low-Frequency Components (Signal)
% Detail(D): Low-Scale, High-Frequency Components (Noise)
s2=L2_C; l_s2=length(s2);
[cA2,cD2] = dwt(s2,'db1'); % Generates the coefficents [Approx, Detail]
A2 = upcoef('a',cA2,'db1',1,l_s2); D2 = upcoef('a',cD2,'db1',1,l_s2);
s3=L3_C; l_s3=length(s3); [cA3,cD3] = dwt(s3,'db1');
A3 = upcoef('a',cA3,'db1',1,l_s3); D3 = upcoef('a',cD3,'db1',1,l_s3);
s4=L4_C; l_s4=length(s4); [cA4,cD4] = dwt(s4,'db1');
A4 = upcoef('a',cA4,'db1',1,l_s4); D4 = upcoef('a',cD4,'db1',1,l_s4);
%% Regression Attempt
t = L2_E; y = s4+s2;
figure; plot(t,y,'r'); title('Data');
%% Problem Area...
F = @(x,xdata)(A2*x(1))+(A3*x(2))+(A4*x(3))+(A5*x(4));
x0 = [0 0 1 0];
[x,resnorm] = lsqcurvefit(F,x0,t,y)
hold on plot(t,F(x,t)); legend('"Raw"','LSR Fit');
I've found plenty of examples relating to the wavelet toolbox and the denoising stuf, but I'm missing something between using the wavelet commands and being able to actually generate a wavelet function. I'm fairly it's that the wavelets are being applied as filters instead of creating the necessary functions, but I haven't been able to find anything indicating how to actually create the function. Can anyone provide advice or help on what I should be doing instead?
  2 Comments
Jess
Jess on 4 Mar 2014
So if I go through the wavelet toolbox instead of using the denoising commands like I had initially done, how would I get the parameters of the wavelet that models the initial signal? It may be a basic question, but almost every example I've found related to wavelets, including the majority of the manual, focuses on using preset wavelets or image analysis applications rather than generating the parameters of the wavelet that would fit a particular signal.
Tubi
Tubi on 22 Mar 2017
Hi Jess, to generate/derive new wavelet functions, I think you can work on curve fitting??!!! I am not certain sure on this!! but, it seems work ok?!

Sign in to comment.

Answers (1)

Wayne King
Wayne King on 28 Feb 2014
Wavelets are continuous in time (space) so you can't actually generate them in the MATLAB per se, but you can use wavefun() to see them for a specified filter. In wavelets derived from a multiresolution analysis, the scaling filter determines the wavelet.
For example:
[phi,psi,xval] = wavefun('db4');
subplot(211)
plot(xval,phi); title('Scaling Function');
subplot(212)
plot(xval,psi); title('Wavelet Function')
  3 Comments
Wayne King
Wayne King on 28 Feb 2014
Edited: Wayne King on 28 Feb 2014
Yes, there are wavelet bases and frames that can represent a signal exactly or approximate the signal at certain scales or positions of interest and that is absolutely doable with the Wavelet Toolbox using discrete and continuous wavelet transforms. Can you attach a representative paper?
Jess
Jess on 3 Mar 2014
Sorry for the delayed response, I've attached an example of one of the papers I had been looking at. The way I was understand the paper, the author chose a particular scale, and used it to model the signal as a wavelet.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!