Spectral Entropy vs Frequency

3 次查看(过去 30 天)
Julian M
Julian M 2020-8-12
I use pentropy(x,sampx) function to calculate spectral entropy distribution for a signal.
The function plots spectral entropy versus time.
However, I need to plot spectral entropy versus frequency.
Does anyone know a function in matlab to do it?

回答(2 个)

Star Strider
Star Strider 2020-8-12
Plotting spectral entropy as a function of frequency is actually described in the documentation in: Plot Spectral Entropy of Speech Signal Note that because the entropy spectrum varies withh time, it will be necessary to plot the result as a spectrogram, as described in the documentation section linked to here. A Fourier transform alone will not produce the appropriate result.
  4 个评论
Julian M
Julian M 2020-8-13
Yes, you were right it wasn't about a continious signal.
However, the example plots a color map with some predefined frequency bins.
Is there a way to evaluate entropy value at some frequency values rather than frequency ranges?
The reason I am asking is that I need to draw a xy plot with x as frequency and y as entropy axes.
Star Strider
Star Strider 2020-8-13
Thank you.
It depends what you want. The second figure here (‘Individual Frequency Bins As Function Of Time’ that I added to an example in the documentation) demonstrates how to access the individual frequency bins displayed in the spectrogram plot. I offset them here for the plot. Access them as rows of ‘se2’ in the example code. The frequency band (bin) limits correspond to the elements of ‘flow’ and ‘fup’. In the third figure, I took a shot at plotting entropy as a function of frequency. (This is simply my best guess as to what it would be. I have no idea what you want to do.)
load Hello x
fs = 44100;
t = 1/fs*(0:length(x)-1);
x1 = x(:,1) + 0.01*randn(length(x),1);
[p,fp,tp] = pspectrum(x1,fs,'FrequencyResolution',20,'spectrogram');
flow = [300 628 1064 1634 2394];
fup = [627 1060 1633 2393 3400];
se2 = zeros(length(flow),size(p,2));
for i = 1:length(flow)
se2(i,:) = pentropy(p,fp,tp,'FrequencyLimits',[flow(i) fup(i)]);
end
subplot(2,1,1)
plot(t,x1)
xlabel('Time (seconds)')
ylabel('Speech Signal')
subplot(2,1,2)
imagesc(tp,[],flip(se2)) % Flip se2 so its plot corresponds to the ascending frequency bins.
h = colorbar(gca,'NorthOutside');
ylabel(h,'Spectral Entropy')
yticks(1:5)
set(gca,'YTickLabel',num2str((5:-1:1).')) % Label the ticks for the ascending bins.
xlabel('Time (seconds)')
ylabel('Frequency Bin')
figure
plot(tp, ((0:4).'+se2))
grid
title('Individual Frequency Bins As Function Of Time')
xlabel('Time')
ylabel('Frequency Bin')
freqmean = mean([flow; fup]);
freqmult = freqmean(:)+ones(size(se2));
figure
plot(freqmult.', se2.')
grid
title('Entropy As Function Of Frequency')
xlabel('Midband Frequency')
ylabel('se2 Row')
grid
.

请先登录,再进行评论。


hosein Javan
hosein Javan 2020-8-12
编辑:hosein Javan 2020-8-12
using fft (Fast Fourier Transform). I'll give you an example.
suppose you have a discrete signal called "x[n]" that has been sampled with a sampling frequency of "Fs". do the following to achieve your frequency spectrum.
N = length(x); % signal length (samples)
a = 1/N*fft(x); % complex fourier series coefficients require 1/N for fft
X = a(1:N/2+1);
X(2:(N-1)/2+1) = 2*X(2:(N-1)/2+1); % your frequency spectrum. X(i)=fourier coefficient of harmonic(i)
  2 个评论
Julian M
Julian M 2020-8-12
I need to plot spectral entropy vs frequency not fft.
Spectral entropy is calculated using pentropy(x,sampx) function in matlab:
However, as I wrote in my question I need to plot spectral entropy versus frequency.
hosein Javan
hosein Javan 2020-8-12
if you have a signal vs time, no matter what, you can extract its frequency-domain data using fft. I don't know if pentropy is no ordinary signal. refer to Star Strider comment if there is something special about this signal that I couldn't answer.

请先登录,再进行评论。

类别

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