Time resolution of Spectral Entropy - How could I modify it?

12 visualizaciones (últimos 30 días)
John Navarro
John Navarro el 10 de Mzo. de 2021
Comentada: John Navarro el 12 de Oct. de 2021
Hello everyone,
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)
mean(diff(te))
ans =
0.02997
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.

Respuesta aceptada

Yazan
Yazan el 11 de Ag. de 2021
Editada: Yazan el 12 de Oct. de 2021
You need to provide the spectrogram to the Matlab function, and this spectrogram should have your desired time resolution.
See the example below.
clc, clear
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)));
Spectral entropy estimated every 0.0199707 sec

Más respuestas (0)

Categorías

Más información sobre Spectral Measurements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by