How to get the frequency,time and energy data sets of wavelet and hht?

4 views (last 30 days)
Hi, I have got the wavelet plot and hht plot of my raw data. Now I want to get the frequency, time and energy data of those wavelet and hht plot such that I can reproduce those plots at a later time using those data and it is required for my other calculations as well... For hht I have seen that sparsh array and for wavelet also get a matrix.but how to know which one is frequency data and which one is time or energy data. And I need to save these datas in a file.how to do that? Thank you.

Answers (1)

Nithin
Nithin on 18 Dec 2023
Hi Joya,
I understand that you want to extract the frequency, time and energy data from wavelet and HHT (Hilbert-Huang Transform) plots in MATLAB.
To extract the above components from wavelet plot, kindly use the "cwt" function which performs coninuous wavelet transform and returns a matrix where each row corresponds to a frequency and each column corresponds to a time point.
t = 0:0.001:1;
data = cos(2*pi*50*t) + cos(2*pi*100*t); % sample data
Fs = 1000;
[wt, f] = cwt(data, 'amor', Fs); % considering 'amor' as the example wavelet
% 'wt' is the complex wavelet coefficients matrix
% 'f' is the frequency array corresponding to the rows of 'wt'
% Calculating the wavelet power spectrum (energy):
power = abs(wt).^2;
% Time array:
t = (0:length(data)-1)/Fs;
% Saving the time, frequency, and energy data to a file:
save('wavelet_data.mat', 't', 'f', 'power');
To extract the above components from HHT plot, kindly perform HHT using EMD (Empirical Mode Decomposition) and Hilbert spectral analysis as shown in the following code snippet :
% Performing EMD on the data:
imfs = emd(data);
% Pre-allocating arrays for time, frequency and energy:
inst_freq = [];
inst_energy = [];
t = (0:length(data)-1)/Fs;
% Looping through each IMF to perform Hilbert transform and extract data:
for i = 1:size(imfs, 2)
h = hilbert(imfs(:, i));
inst_energy(:, i) = abs(h).^2; % Instantaneous energy
inst_freq(:, i) = Fs/(2*pi)*diff(unwrap(angle(h))); % Instantaneous frequency
end
% Saving the time, frequency, and energy data to a file:
save('hht_data.mat', 't', 'inst_freq', 'inst_energy');
For more information regarding "cwt", "emd" and "hilbert" functions in MATLAB, kindly refer to the following documentation:
I hope this answer helps you.
Regards,
Nithin Kumar.

Community Treasure Hunt

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

Start Hunting!