main content

using wavelet time-凯发k8网页登录

this example shows how to use the app to visualize the scalogram of a 1-d signal. the scalogram is the absolute value of the continuous wavelet transform (cwt). you can adjust wavelet parameters, voices per octave, and frequency limits to use in the cwt. you can compare multiple scalograms and export a scalogram to your workspace. you can also recreate the scalogram in your workspace by generating a matlab® script.

import data

load the wecg signal into the matlab workspace. the sampling frequency is 180 hz.

load wecg
fs = 180;

visualize scalogram

open wavelet time-frequency analyzer. on the analyzer tab, click import signals. a window appears with a list of all the workspace variables the app can process. select the wecg signal and click import. after a brief, one-time initialization, the name and type of the imported signal populates the signals pane. the app displays the scalogram in the scalogram-wecg plot. the app generates the scalogram using the analytic morse (3, 60) wavelet and the function with default settings. the cone of influence shows areas in the scalogram potentially affected by edge-effect artifacts. you should treat shaded regions outside the dashed white lines as suspect due to the potential for edge effects. to learn more about the cone of influence, see .

you can hide or display the cone of influence boundary line or shade the boundary region by setting the option in the preferences ▼ menu. if the signal is complex-valued, you can also choose to display the positive (counterclockwise) and negative (clockwise) components as either separate or concatenated scalograms. the options you choose in the preferences ▼ menu persist across matlab sessions.

by default, because the signal is not a timetable, the app plots the frequencies in cycles/sample, and uses the sample index as the basis of the time axis. if the imported signal is a timetable, the app plots the scalogram as a function of frequency in hertz and uses the row times of the timetable as the basis for the time axis.

on the analyzer tab, select the sample rate radio button. the axes labels in the scalogram update using the default sampling rate of 1 hz. to set the axes labels appropriately for the wecg signal, apply the value 180 in the sample rate field. you cannot modify the sample rate for timetables.

afterimport.png

modify wavelet parameters

to access the cwt parameters used to create the scalogram, click the scalogram tab. the parameters correspond to input arguments of the function. parameter settings are the default values. because you set the sampling rate, the minimum and maximum frequency limits are in hertz. the default frequency limits depend on the wavelet, signal length, sampling rate, and voices per octave. for more information, see .

scalogramtabshorter.png

to obtain the scalogram using the morse (40,60) wavelet, first, change the morse symmetry parameter in the symmetry text box to 40. then, to enter the new value, either press the enter key on your keyboard or click the mouse anywhere outside the text box.

  • the compute scalogram button is now enabled.

  • the frequency limits update because you changed the wavelet.

  • in the status bar, text appears stating there are pending changes.

you can reset the cwt parameters to their default values at any time by clicking reset parameters. resetting the parameters enables the compute scalogram button.

note: to prevent invalid settings, the app immediately validates any parameter you change. if you enter an invalid value, the app automatically replaces it with a valid value. the app treats the following values as invalid:

  • a very low minimum frequency value

  • a time-bandwidth product value that violates a constraint the morse wavelet parameters must satisfy

the new value might not be the desired value. to avoid unexpected results, you should ensure any value you enter always results in a valid setting. for more information, see the example .

setsymto40.png

to apply your changes and visualize the new scalogram, click compute scalogram.

scalogramat40.png

compare scalograms

to compare the current scalogram with one obtained using the bump wavelet, first click the duplicate button on the analyzer tab. a second signal, wecgcopy, appears in the signals pane. the scalogram of the duplicate appears in the scalogram-wecgcopy plot. then in the scalogram tab, select bump from the wavelet dropdown menu. observe the morse wavelet parameters are now disabled, and the frequency limits are updated. to create the scalogram with the bump wavelet, click compute scalogram. to compare with the first scalogram, select wecg in the signals pane.

bumpscalo2.png

export results

you can export a structure array to your workspace that contains the cwt of the selected signal. you can also generate a matlab® script to recreate the scalogram in your workspace.

export structure

to export the cwt of wecgcopy, select that signal in the signals pane. then select export scalogram from the export ▼ menu to create the structure array wecgcopy_scalogram in your workspace. the structure array has three fields:

  • coefficients — cwt coefficients

  • frequencyvector — scale-to-frequency conversions

  • timevector — time vector

you can use the field values to visualize the scalogram in a new figure by executing these commands:

figure
pcolor(wecgcopy_scalogram.timevector, ...
    wecgcopy_scalogram.frequencyvector, ...
    abs(wecgcopy_scalogram.coefficients))
shading flat
set(gca,"yscale","log")
title("scalogram")
xlabel("time (s)")
ylabel("frequency (hz)")

generate script

to generate a script that recreates the scalogram of the wecg signal in your workspace, select the wecg signal in the signals pane. then select generate matlab script from the export ▼ menu. the app generates the script using the name of the signal you selected in the signals pane. an untitled script opens in your matlab editor with the following executable code.

%parameters
samplerate = 180;
waveletparameters = [40,60];
%compute time vector
t = 0:1/samplerate:(length(wecg)*1/samplerate)-1/samplerate;
%compute cwt
%if necessary, substitute workspace variable name for wecg as first input to cwt() function in code below
%run the function call below without output arguments to plot the results
[wavelettransform,frequency] = cwt(wecg, samplerate,...
    waveletparameters = waveletparameters);
scalogram = abs(wavelettransform);

save and execute the script. you can use the workspace variables scalogram, t, and frequency to visualize the scalogram.

subplot(2,1,1)
pcolor(t,frequency,scalogram)
shading flat
set(gca,"yscale","log")
title("scalogram")
ylabel("frequency (hz)")
xlabel("time (s)")
subplot(2,1,2)
plot(t,wecg)
axis tight
title("signal")
xlabel("time (s)")

figure contains 2 axes objects. axes object 1 with title scalogram, xlabel time (s), ylabel frequency (hz) contains an object of type surface. axes object 2 with title signal, xlabel time (s) contains an object of type line.

see also

apps

  • |

functions

  • | | |

related topics

    网站地图