Time resolution of Spectral Entropy - How could I modify it?
13 views (last 30 days)
I have a signal (a timetable of 307,200 data points) with sampling rate of 20480 Hz (0.00005s) and total length of 15.0 seconds.
When I apply the command pentropy I get a time vector te with length 500 points, equivalent to a time resolution of 0.03 seconds
I confirmed this value as shown below. The problem is that I need the spectral entropy of the signal every 0.02 seconds and every 0.05 seconds.
Is any way where I can adjust or define this "time resolution"?
[se,te] = pentropy(Datos01.Sensor1,Fs)
Could someone help me? Thanks
P.S. I was planning to use the retime command and @pentropy as input but it sends me an error. See Below
Other alternative would be using a for and a moving window but not sure how to code it
DatosA = retime(Datos01,"regular",@pentropy,"TimeStep",seconds(windowLength));
% Error using timetable/retime (line 140)
% Applying the function 'pentropy' to the 1st group in the variable 'Sensor01' generated the following error:
% Expected input argument 2 to be time information in the form of a numeric scalar as sampling frequency, a duration
% scalar as sampling time or a numeric/duration/datetime array as time values.
Yazan on 11 Aug 2021
Edited: Yazan on 12 Oct 2021
You need to provide the spectrogram to the Matlab function, and this spectrogram should have your desired time resolution.
See the example below.
fs = 20480;
f = 0.01*fs;
ts = 1/fs;
t = 0:ts:15-ts;
x = cos(2*pi*f*t);
% compute power spectrogram with time resolution equal to 0.02 sec
% note that the overlap between the spectrogram windows is set to zero
% if you introduce overlap between the windows, the time resolution should
% be changed to guarantee that 'tp' is sampled every 0.02 sec
[p, fp, tp] = pspectrum(x, fs, 'TimeResolution', 0.02, 'OverlapPercent', 0, 'spectrogram');
% compute spectral entropy
[se, te] = pentropy(p, fp, tp);
fprintf('Spectral entropy estimated every %g sec\n', mean(diff(te)));