why wavelet doesn't show accurate results always?

3 views (last 30 days)
I have a signal that contains some modes in it. I've run a CWT transform but I haven't got my desired results. so I implement a test signal that contains freqs [0.1,0.3,0.6] Hz to see whats the problem with my codes. but the result was accurate. once I change the freqs to [0.1,0.4,0.6] or [0.1,0.5,0.6]Hz,The results wasn't accurate anymore on the plot. you can see the plot here, http://cubeupload.com/im/4msYBt.jpg.It might be for the damping effect of the 0.6Hz mode or ... I don't know actually :( I think I must fix why this happening first to get my actual signal modes. here's my codes.
t=linspace(0,30,300);
Fs=ceil(inv(t(2)-t(1))); % sampling freq
x=sin(2*pi*t*0.1).*(t<10)+sin(2*pi*t*0.3).*...
(t<30)+sin(2*pi*t*0.6).*(t<10).*exp(-t*.1); % my signal[0.1Hz,0.3Hz,0.6Hz]
wname = 'morl'; % define wavelet name
scales = 1:1:128; % scales range
coefs = cwt(x,scales,wname,'lvlabs'); % Get coefs of x
freq = scal2frq(scales,wname,1/Fs); %convert scales to freq range
surf(t,freq,abs(coefs));shading('interp'); % 3D surface plot
axis tight; xlabel('Seconds'); ylabel... % seting the axis 3D surface
('Pseudo-Frequency (Hz)'); % seting the axis 3D surface
axis([0 length(t)/Fs 0 1 0 max(coefs(:))*1.1]) % seting the axis 3D surface
figure;
sc=wscalogram('image',coefs,'scales',freq,'ydata',x); % get scalograme of x
xlabel('Time'); ylabel('Frequency of gen'); % set axis
hold on
abscof=abs(coefs)'; % |coefs|'
modI=max(abscof); % get max |coefs| coresponde to freqs of x
modI=modI/max(modI); % scale each clumn 0-1
figure;
plot(freq,modI) % Plot all modes. contain all
grid on
axis([0 1 0 max(modI)*1.1]) % seting the axis
xlabel('Pseudo-Frequency (Hz)'); ylabel('abs(coefs)'); % seting the axis
  4 Comments
Jan
Jan on 4 Aug 2013
Edited: Jan on 4 Aug 2013
Thank you for adding a link to the cross-posting. Please note that such cross posting is not liked in forums.
Formatting is easy: Insert a blank line before and after the code, mark the code block and press the "{} Code" button. It is explained clearly when you follow the "? Help" link or search in the forum for one of the more than 2000 explanation, which have been given in the past. And if you still have questions about the forum, feel free to ask.
Notice that seeing the not readable code does not encourage to post an answer, even if the question is posted in a nicer form anywhere else.

Sign in to comment.

Accepted Answer

Wayne King
Wayne King on 4 Aug 2013
I'm not quite sure why you say this:
t=linspace(0,30,300);
Fs=ceil(inv(t(2)-t(1)));
x=sin(2*pi*t*0.1).*(t<10)+sin(2*pi*t*0.4).*...
(t<30)+sin(2*pi*t*0.6).*(t<10).*exp(-t*.1);
scales = 10:0.1:150;
wname = 'morl';
coefs = cwt(x,scales,wname);
freq = scal2frq(scales,wname,dt);
contour(t,freq,abs(coefs));shading('interp');
axis tight;
xlabel('Time'); ylabel('Pseudo-frequency (Hz)');
You have to keep in mind that the wavelet yields a bandpass analysis.
  1 Comment
Jamais avenir
Jamais avenir on 4 Aug 2013
I didn't understand you. Have you looked at http://cubeupload.com/im/4msYBt.jpg . what do you mean by saying "bandpass analysis". tnx for answer.

Sign in to comment.

More Answers (1)

Wayne King
Wayne King on 4 Aug 2013
Edited: Wayne King on 4 Aug 2013
Wavelets have bandwidth, they are not like the complex exponentials of Fourier analysis. The larger the scale, the narrow the bandwidth of the analyzing wavelet in the Fourier domain.
Write down the expression for the wavelet transform in the Fourier domain, you'll see that it is a bandpass filtering of the signal with the bandwidth inversely proportional to scale. The actual bandwidth of course depends on the analyzing wavelet.
You are going to have difficulty with a signal where you want wavelet analysis to pick up the difference between 0.4 and 0.6 Hz.
Look at how well the wavelet analysis does when the separation between 0.4 and 0.6 is increased to 0.4 and 1 Hz and you actually include two periods of the 0.1 Hz wave.
t=linspace(0,30,300);
Fs=ceil(inv(t(2)-t(1)));
x=sin(2*pi*t*0.1).*(t<20)+sin(2*pi*t*0.4).*...
(t<30)+sin(2*pi*t*1).*(t<10).*exp(-t*.1);
scales = 5:0.5:150;
wname = 'morl';
coefs = cwt(x,scales,wname);
freq = scal2frq(scales,wname,dt);
contour(t,freq,abs(coefs));shading('interp');
axis tight; xlabel('Seconds'); ylabel...
('Pseudo-Frequency (Hz)');
set(gca,'ytick',[0.1 0.4 0.6 0.8 1 1.4])
But you can clearly see the effect of the bandwidth of the wavelet in the plot. Note how the oscillation at 0.4 Hz extends into the 0.6 region of frequency space. Further, note how the oscillation at 1 Hz extends further below and above 1 Hz than the effect at 0.4 and 0.1 Hz. That is because the bandwidth of the analyzing Morlet wavelet is larger at 1 Hz than at 0.4 or 0.1 Hz.
  1 Comment
Jamais avenir
Jamais avenir on 4 Aug 2013
Hi Wayne King. thanks for your answer.I have little background of wavelet analysis.I checked your code with 0.1,0.4,1Hz.and it gave accurate output.but how can I get accurate result with 0.1,0.4,0.6 Hz. So you mean with proper setting of morlet bandwidth frequency I can get accurate output for .1,.4,.6Hz too? and if yes, then how can I set customize bandwidth frequency for my wavelet? I don't know what is the role of bandwidth frequency in wavelet actually,would you explain a bit more please? I know how to set Fb-Fc for complex morlet, but dont now for morlet. Also would you look at my other question here http://www.mathworks.com/matlabcentral/answers/83947-what-is-proper-setting-for-fb-fc-in-complex-morlet-wavelet-cmor you will see what i have done so far. Thanks in advance

Sign in to comment.

Products

Community Treasure Hunt

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

Start Hunting!