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

조회 수: 11 (최근 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)
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.

채택된 답변

Yazan
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개)

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by