Following code, when run shows "Error using wthcoef (line 58). Invalid level value". What do I do to correct it?
6 次查看(过去 30 天)
显示 更早的评论
[c,l] = wavedec(yNoisy,7,'db4');
approx = appcoef(c,l,'db4');
[cd1,cd2,cd3,cd4,cd5,cd6,cd7] = detcoef(c,l,[1 2 3 4 5 6 7]);
thr_approx = thselect(approx,'rigrsure');
thr_cd7 = thselect(cd7,'rigrsure');
thr_cd6 = thselect(cd6,'rigrsure');
thr_cd5 = thselect(cd5,'rigrsure');
thr_cd4 = thselect(cd4,'rigrsure');
thr_cd3 = thselect(cd3,'rigrsure');
thr_cd2 = thselect(cd2,'rigrsure');
thr_cd1 = thselect(cd1,'rigrsure');
thr = [thr_cd7 thr_cd6 thr_cd5 thr_cd4 thr_cd3 thr_cd2 thr_cd1]
nc = wthcoef('t',c,l,1:8,thr,'s');
0 个评论
回答(1 个)
Ayush
2024-1-2
编辑:Ayush
2024-1-2
Hi @Sayan Mitra
I understand that you are getting the Invalid level value error. In your code, you have decomposed your signal yNoisy using the wavedec function up to level 7. However, when you are calling wthcoef, you're attempting to threshold levels 1 to 8, which is incorrect because you only have levels 1 to 7 available from your wavelet decomposition. You may refer to the documentation to see how to define the Detail levels in wthcoef: https://www.mathworks.com/help/wavelet/ref/wthcoef.html#mw_b067152c-8868-4892-9926-2a16c1ad16af
You may try this:
% Initialize the new coefficients array
nc = c;
% Threshold coefficients for each level
for lvl = 7:-1:1
nc = wthcoef('t', nc, l, lvl, thr(lvl), 's');
end
Thanks
Ayush
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Digital Filtering 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!