getting contents of db6 wavelet filters

2 views (last 30 days)
tren
tren on 1 Jun 2025
Answered: Umeshraja on 17 Jun 2025
Hi,
I need to decompose a signal using wavelet 'db6' transform and analyze its components.
I want to perform 6 level decomposition and then add low/hi filter contents to see results (see attached Fig).
e.g., i want to add: d1+d2, a6+d6 etc.
My code provides me fixed 6 values in details and that too of varying sample lengths:
x=signal_of_interest;
N = 6; % Example decomposition level
[C,L] = wavedec(x, N, 'db6');
% Extract detail coefficients
details = detcoef(C,L,'cells');
% Visualize the coefficients
figure;
subplot(N+1,1,1); plot(details{1}); title('Level 1');
hold on;
for i=2:N
subplot(N+1,1,i); plot(details{i}); title(sprintf('Level %d',i));
hold on;
end
% (Optional) Plot the approximation coefficients
approximation = wrcoef('a',C,L,'db6');
subplot(N+1,1,N+1); plot(approximation); title('Approximation');
Please let me know how i can get both low and high pass contents of filters (as shown in attached Fig) like a1,a1,a6,d1,d2,d6....
Thanks
  1 Comment
William Rose
William Rose on 2 Jun 2025
@tren, Please provide signal_of_interest, so that others can experiment with your script.

Sign in to comment.

Answers (1)

Umeshraja
Umeshraja on 17 Jun 2025
Hi @tren,
I understand you are able to extract detail coefficient d1,..d6 using detcoeff but wanted to extract approximation coefficients at the coarsest scale. You can use appcoef function of wavelet toolbox to extract a1,..a6.
Below is the small example demonstrating how to extract and visualize the approximation coefficients at all levels from a 5-level discrete wavelet transform (DWT) using the 'sym4' wavelet in MATLAB
% Load the leleccum dataset
load leleccum;
% Perform 5-level wavelet decomposition using 'sym4' wavelet
[c, l] = wavedec(leleccum, 5, 'sym4');
% Number of decomposition levels
numLevels = 5;
% Create a tiled layout for plotting
tiledlayout(numLevels + 1, 1)
% Plot the original signal
nexttile
plot(leleccum)
title('Original Signal')
axis tight
% Extract and plot approximation coefficients for each level
for lev = 1:numLevels
a = appcoef(c, l, 'sym4', lev);
nexttile
plot(a)
title(['Level ' num2str(lev) ' Approximation Coefficients'])
axis tight
end
Please refer to the following documentation to know more on approximate coefficients
Hope it helps!

Products


Release

R2017b

Community Treasure Hunt

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

Start Hunting!