Spectral Entropy vs Frequency
Mostrar comentarios más antiguos
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?
Respuestas (2)
Star Strider
el 12 de Ag. de 2020
1 voto
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 comentarios
Julian M
el 12 de Ag. de 2020
Star Strider
el 12 de Ag. de 2020
It is a discrete signal, since it is sampled.
Running:
C = matfile('Hello')
returns (on my computer):
C =
matlab.io.MatFile
Properties:
Properties.Source: 'C:\Program Files\MATLAB\R2020a\examples\signal\data\Hello.mat'
Properties.Writable: false
x: [220500x2 double]
The documentation also uses it and refers to it as a discrete signal.
Note that — except for the output of the soundcard — everything in a computer is discrete and sampled.
Julian M
el 13 de Ag. de 2020
Star Strider
el 13 de Ag. de 2020
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
el 12 de Ag. de 2020
Editada: hosein Javan
el 12 de Ag. de 2020
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 comentarios
Julian M
el 12 de Ag. de 2020
hosein Javan
el 12 de Ag. de 2020
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.
Categorías
Más información sobre Spectral Measurements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!