I am running Morlet continuous wavelet transform. I have got wscalogram
of signal and now I want to plot freq-magnitude like the following picture., but I don't know how to do it:
I've used scal2freq
MATLAB function to convert scales to pseudo frequencies. Also I have some frequencies in my signal that have a large damping ratio(4%) so they are not well visible in plot. How can I exaggerate these highly damped modes?
I am using MATLAB, here is my codes:
% Import the text4.txt to matlab workspace. and save it under name "data"
t=linspace(0,30,301);
Fs=ceil(inv(t(2)-t(1)));
x=data(:,4); % use x=data(:,3),x=data(:,5) too. first column is time,second is refrence
wname = 'morl';
scales = 1:1:256;
coefs = cwt(x,scales,wname,'lvlabs');
freq = scal2frq(scales,wname,1/Fs);
surf(t,freq,abs(coefs));shading('interp');
axis tight; xlabel('Seconds'); ylabel('Pseudo-Frequency (Hz)');
axis([0 30 0 1 0 60])
xlabel('Time'); ylabel('Frequency');
figure;
sc=wscalogram('image',coefs,'scales',freq,'ydata',x);
hold on
My current plot looks like this:
Answer
Modifying your code a little bit, but no major changes, and I get correct results either way. Use this template code here, and you should not see any problems. I get the correct results.
clear all;
t=linspace(0,30,301);
Fs = (inv(t(2)-t(1)));
x=randn(100,1);
wname = 'morl';
scales = 1:1:256;
chefs = cwt(x,scales,wname,'lvlabs');
freq = scal2frq(scales,wname,1/Fs);
figure;
coefsSquared = abs(coefs).^2;
imagesc(coefsSquared);
grid off;
%Pick one of the columsn to plot:
figure;
plot(coefsSquared(:,47))
To get the figure on the right hand side of the first image you put up, that is simply the time-slice spectrum. In other words, one column of your frequency-time matrix.
For example, we might get the following squared-coefficient matrix, in frequency vs. time:
Let us then suppose we wish to look at the spectrum for the time-slice at column 47. Then, this is given here:
Here, you then see the power of the coefficients, vs. frequency, for the time-slice corresponding to column 47.
No comments:
Post a Comment