How do I extract the raw data from a plot made using the cwt function?
Afficher commentaires plus anciens
I have imported data and then used the cwt function to perform a continuous wavelet transform on that data, but now I would like to access the raw data Matlab used to make the plot. Nothing new is created in my workspace so I'm kind of at a lost for how to access a spreadsheet of values corresponding to the created cwt figure.
6 commentaires
Mathieu NOE
le 29 Avr 2021
hello Claire
why cwt function did you use ? there is probably a way to get the values and not only a plot
tx
Jonas
le 29 Avr 2021
if you are interested how the graph is created you can have a look into the example "Plot CWT Scalogram in Subplot" of the cwt frunction.
Claire Smith
le 29 Avr 2021
Claire Smith
le 29 Avr 2021
Mathieu NOE
le 29 Avr 2021
hello Claire
I have to admit I do not use the cwt function but the doc says ( should be one syntax that should give the required access to the data)
Description
wt = cwt(x) returns the continuous wavelet transform (CWT) of x. The input, x, is a real- or complex-valued vector, or a single-variable regularly sampled timetable, and must have at least four samples. The CWT is obtained using the analytic Morse wavelet with the symmetry parameter (gamma) equal to 3 and the time-bandwidth product equal to 60. cwt uses 10 voices per octave. The minimum and maximum scales are determined automatically based on the energy spread of the wavelet in frequency and time. If x is real-valued, wt is a 2-D matrix where each row corresponds to one scale. The column size of wt is equal to the length of x. If x is complex-valued, wt is a 3-D matrix, where the first page is the CWT for the positive scales (analytic part or counterclockwise component) and the second page is the CWT for the negative scales (anti-analytic part or clockwise component).
The cwt function uses L1 normalization. With L1 normalization, if you have equal amplitude oscillatory components in your data at different scales, they will have equal magnitude in the CWT. Using L1 normalization shows a more accurate representation of the signal. See L1 Norm for CWT and Continuous Wavelet Transform of Two Complex Exponentials.
wt = cwt(x,wname) uses the analytic wavelet specified by wname to compute the CWT. Valid options for wname are 'morse', 'amor', and 'bump', which specify the Morse, Morlet (Gabor), and bump wavelet, respectively. If you do not specify wname, wname defaults to 'morse'.
[wt,f] = cwt(___,fs) specifies the sampling frequency, fs, in Hz as a positive scalar. cwt uses fs to determine the scale-to-frequency conversions and returns the frequencies f in Hz. If you do not specify a sampling frequency, cwt returns f in cycles per sample. If the input x is complex, the scale-to-frequency conversions apply to both pages of wt. If x is a timetable, you cannot specify fs. fs is determined from the RowTimes of the timetable.
[wt,period] = cwt(___,ts) specifies the sampling period, ts, as a positive duration scalar. The duration can be in years, days, hours, minutes, or seconds. cwt uses ts to compute the scale-to-period conversion and returns the time periods in period. The array of durations in period has the same format property as ts. If the input x is complex, the scale-to-period conversions apply to both pages of wt. If x is a timetable, you cannot specify ts. ts is determined from the RowTimes of the timetable when you set the 'PeriodLimits' name-value pair.
[wt,f,coi] = cwt(___,fs) returns the cone of influence, coi, which shows where edge effects of the CWT become significant. The cone of influence for the CWT is in Hz. If the input x is complex, the cone of influence applies to both pages of wt.
[wt,period,coi] = cwt(___,ts) returns the cone of influence, coi, which shows where edge effects of the CWT become significant. The cone of influence for the CWT is in periods. If the input x is complex, the cone of influence applies to both pages of wt.
[___] = cwt(___,Name,Value) returns the CWT with additional options specified by one or more Name,Value pair arguments.
[___,fb,scalingcfs] = cwt(___) returns the scaling coefficients if the analyzing wavelet is 'morse' or 'amor'. Scaling coefficients are not supported for the bump wavelet.
cwt(___) with no output arguments plots the CWT scalogram. The scalogram is the absolute value of the CWT plotted as a function of time and frequency. Frequency is plotted on a logarithmic scale. The cone of influence showing where edge effects become significant is also plotted. Gray regions outside the dashed white line delineate regions where edge effects are significant. If the input signal is complex-valued, the positive (counterclockwise) and negative (clockwise) components are plotted in separate scalograms.
If you do not specify a sampling frequency or sampling period, the frequencies are plotted in cycles per sample. If you specify a sampling frequency, the frequencies are in Hz. If you specify a sampling period, the scalogram is plotted as a function of time and periods. If the input signal is a timetable, the scalogram is plotted as a function of time and frequency in hertz and uses the RowTimes as the basis for the time axis.
To see the time, frequency, and magnitude of a scalogram point, enable data tips in the figure axes toolbar and click the desired point in the scalogram.
JOYA GHOSH DASTIDER
le 21 Mar 2022
Hi, Claire Smith. I am facing the exact same thing described in your very first question.I am using cwt command for my time series data and got the scalogram.Now I want those raw datas of frequency,time and energy shown in the plot. Can you please explain me the way out and what code is needed to extract that? Thank you.
Réponses (1)
Mathieu NOE
le 21 Mar 2022
hello again
maybe try this code. It uses the "another_cwt" function (attached) you can also get from FEX :
https://fr.mathworks.com/matlabcentral/fileexchange/65104-cmccrimm-continuous-wavelet-transform?s_tid=srchtitle
demo code :
clear
load('X.mat')
Fs = 4;
t = (0:numel(Sg)-1)/Fs;
ax = newplot;
[y,f,coi] = another_cwt(Sg,Fs);
% reduction of the dB scale : only display max to min = max - Range_dB
Range_dB = 40; % dB scale
out_dB = 20*log10(abs(y));
ind = find(out_dB< max(out_dB,[],'all')-Range_dB);
out_dB(ind) = NaN;
imagesc(t,f,out_dB);
xlabel('Time (s)')
ylabel('Frequency (Hz)')
colormap('jet(128)')
axis tight;
cb = colorbar(ax);
set(gca,'YDir','normal');
Catégories
En savoir plus sur Continuous Wavelet Transforms dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!