Hi Eashan,
From the information shared, I inferred that you are trying to reconstruct the signal using the 3rd, 4th, and 5th level "wavelet coefficients". The "bookkeeping vector", L provides the lengths of the various levels of decomposition stored in the wavelet coefficients", C. The structure of C is such that it begins with the approximation coefficients at the final level of decomposition, followed by the detail coefficients for each level in descending order.
Given a decomposition up to level N, the structure of C and L is as follows:
- C = [A_N, D_N, D_{N-1}, ..., D_1]
- L = [length(A_N), length(D_N), length(D_{N-1}), ..., length(D_1), original_signal_length]
To reconstruct the signal using just the 3rd, 4th, and 5th level coefficients, the "wavelet coefficients", C can be modified to include only the coefficients needed to reconstruct by setting others to zero. The specific parts of the "bookkeeping vector" are not required.
Assuming 5-level decomposition, here is an example MATLAB R2024A code that can reconstruct the signal using the 3rd, 4th, and 5th level coefficients:
- Creating an example signal for reference:
signal = sin(2 * pi * 5 * t) + 0.5 * sin(2 * pi * 10 * t);
- Decomposition using the MATLAB "wavedec" function and 'db1' wavelet:
[coeffs, L] = wavedec(signal, 5, wname);
- Zeroing out the coefficients that are not required for reconstruction. Here 1st and 2nd level coefficients are reduced to zero:
coeffs(cumL(end-2)+1:cumL(end-1)) = 0;
coeffs(cumL(end-3)+1:cumL(end-2)) = 0;
- Reconstruct the signal using MATLAB "waverec" function:
reconstructed_signal = waverec(coeffs, L, wname);
plot(t, signal, 'b', 'DisplayName', 'Original Signal');
plot(t, reconstructed_signal, 'r--', 'DisplayName', 'Reconstructed Signal');
title('Signal Reconstruction Using Levels 3, 4, and 5');
To understand more about the MATLAB's "wavedec", "cumsum", "waverec" functions, please follow the below mentioned MATLAB R2024A documentation links respectively:
Regards,
Abhimenyu