confused about dimensions of detailed cofficients when apply db3 of level 6
4 views (last 30 days)
Show older comments
I have a cell array comprises of three cell with dimension of 868 by 16 of each cell. When i apply db3 with level 6 on each cell and safe detailed coefficient and approximate coefficient in an array corresponding to original data cells by using Matlab code shown below:
dwt_coeffs_struct = struct('A', cell(size(data)), 'D', cell(size(data)));
% Loop over each cell in the data array
for i = 1:numel(data)
% Convert the cell data to double and reshape it to a column vector
signal = reshape(cell2mat(data{i}), [], 1);
% Initialize arrays to store approximation coefficients and detail coefficients
A_coeffs = cell(1, 6);
D_coeffs = cell(1, 6);
% Perform the DWT for each level
for j = 1:6
[C, L] = wavedec(signal, j, 'db3');
% Store the approximation coefficients and detail coefficients separately
if j == 1
A_coeffs{j} = appcoef(C, L, 'db3', j);
end
D_coeffs{j} = detcoef(C, L, j);
end
% Store the DWT coefficients for this signal in the structure array
dwt_coeffs_struct(i).A = A_coeffs;
dwt_coeffs_struct(i).D = D_coeffs;
end
Than i got detiled cofficents D1=41666 by 1
D2=20835 by 1
D3=10420 by 1
D4=5212 by 1
D5=2608 by 1
D6=1306 by 1
Am i getting correct dimensions of these detailed coffinites ....Please guide so that i may further extract features from these detailed coefficients
0 Comments
Answers (1)
Prathamesh
on 21 Feb 2025
I understand that you have a cell array consisting of three cells, each with dimensions of 868 by 16. After applying a level 6 discrete wavelet transform (DWT) using the 'db3' wavelet on each cell, are the dimensions of the resulting detail and approximation coefficients correctly corresponding to the original data cells?
Here's a corrected version of your code with comments explaining the changes:
dwt_coeffs_struct = struct('A', cell(size(data)), 'D', cell(size(data)));
for i = 1:numel(data)
% Convert the cell data to double and reshape it to a column vector
signal = reshape(cell2mat(data{i}), [], 1);
% Perform the DWT for 6 levels using 'db3' wavelet
[C, L] = wavedec(signal, 6, 'db3');
% Initialize arrays to store approximation coefficients and detail coefficients
A_coeffs = cell(1, 6);
D_coeffs = cell(1, 6);
% Extract approximation coefficients at level 6
A_coeffs{6} = appcoef(C, L, 'db3', 6);
% Extract detail coefficients for each level
for j = 1:6
D_coeffs{j} = detcoef(C, L, j);
end
% Store the DWT coefficients for this signal in the structure array
dwt_coeffs_struct(i).A = A_coeffs;
dwt_coeffs_struct(i).D = D_coeffs;
end
for i = 1:numel(data)
fprintf('Detail Coefficients for signal %d:\n', i);
for j = 1:6
fprintf('D%d: %d by 1\n', j, length(dwt_coeffs_struct(i).D{j}));
end
end
Key Corrections:
Signal Reshaping : Ensure that each cell's data is reshaped to a column vector before applying the DWT. This step is crucial to maintain the integrity of the signal.
Coefficient Storage: Store the approximation coefficients only at the highest level (level 6). Store detail coefficients for each level from 1 to 6.
Correct Usage of wavedec: The 'wavedec' function is correctly used to decompose the signal up to the specified level.
0 Comments
See Also
Categories
Find more on Large Files and Big Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!