Discrete Wavelet analysis code problem
4 次查看(过去 30 天)
显示 更早的评论
Hi
So, I'm trying to code a program that computes and displays the Discrete wavelet analysis over a certain number of levels of an imported signal using the wavedec function. But I have a problem running it so far since I've got these 2 errors :
Error using appcoef (line 39)
Invalid level value.
Error in Ondelette (line 12)
ap4=appcoef(c,1,'db2',4);
The code is as shown below :
clear all ;
close all ;
clc ;
s = dlmread('I1V1500.txt','\t');
whos
sig = s ;
longsig=length(sig);
[c.l]=wavedec(sig,4,'db2');
ap4=appcoef(c,1,'db2',4);
ap3=appcoef(c,1,'db2',3);
ap2=appcoef(c,1,'db2',2);
ap1=appcoef(c,1,'db2',1);
d4=detcoef(c,l,4);
d3=detcoef(c,l,3);
d2=detcoef(c,l,2);
d1=detcoef(c,1,1);
figure ;
subplot(5.2,1);plot(sig);
I've also joined the imported file in question.
I'd be grateful if someone could help me solve my problem.
Thanks in advance
回答(1 个)
Walter Roberson
2015-11-24
[c.l]=wavedec(sig,4,'db2');
should be
[c, L]=wavedec(sig,4,'db2');
You were accidentally outputting to a structure field instead of to two different variables.
And
ap4=appcoef(c,1,'db2',4);
ap3=appcoef(c,1,'db2',3);
ap2=appcoef(c,1,'db2',2);
ap1=appcoef(c,1,'db2',1);
should be
ap4=appcoef(c,L,'db2',4);
ap3=appcoef(c,L,'db2',3);
ap2=appcoef(c,L,'db2',2);
ap1=appcoef(c,L,'db2',1);
You were passing in the digit 1 instead of the letter lower-case L.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Discrete Multiresolution Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!