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

16 ビュー (過去 30 日間)
John Navarro
John Navarro 2021 年 3 月 10 日
コメント済み: John Navarro 2021 年 10 月 12 日
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)
ans =
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 2021 年 8 月 11 日
編集済み: Yazan 2021 年 10 月 12 日
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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by