Hi,i am trying to run the following program,but it shows index out of bounds .length of my signal loaded is=10240 and when i am taking square for x ,it shows index out of bounds error and also one more error is undefined function chebyshev
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
poornima.a A
el 27 de En. de 2018
Comentada: Faizul Hakim
el 17 de Oct. de 2022
function segmentation_Shennon
close all
clear all
% Load the data file
[F, Fs] = audioread ('1.wav');
pcg = F (:, 2);
t = 0: 1 / Fs: (length (F) -1) / Fs;
%%We normalize and filter the signal with a Chebyshev filter of 1 8th order NP with a frequency of medium 882 Hz
pcg_filter = chebushev1 (pcg, Fs);
pcg_norm = pcg_filter./abs(max(pcg_filter));
% calculate the energy of Shannon
shennon_energy = - ((pcg_norm. ^ 2). * log (pcg_norm. ^ 2));
figure (1)
plot (t, shennon_energy)
% calculate the average Shannon energy in a segment lasting 0.02 s
% with an overlap of 0.01 s
win = 0.002 * Fs;
i = 1;
k = 1;
Es = [];
Es_t = [];
P = [];
while i <length (pcg_norm)
for i = i: i + win
square = pcg_norm (i). ^ 2;
Es (k) = -1 / win * sum (square. * Log (square));
end
ES_t (k) = t (i);
i = i + round (win / 2);
k = k + 1;
end
% we normalize Shannon's averaged energy
M_Es = (mean (Es)); % mean energy of the segment
S_Es = (std (Es (k-1))); % standard deviation of the energy of the segment
P (k) = (Es (k-1) -M_Es) / S_Es; % Shannon's normalized averaged energy,
plot (t, P)
1 comentario
Greg
el 27 de En. de 2018
Highlight your code and then click the {} code button to help format it so we can read it.
Respuesta aceptada
Walter Roberson
el 28 de En. de 2018
You appear to have a typing mistake: you used chebushev1 but the English version of the name is chebyshev . However there is no chebyshev1 function: there is cheby1 https://www.mathworks.com/help/signal/ref/cheb1ord.html and there is the MuPAD orthopoly:chebyshev1 which is not likely what you are wanting to call.
With respect to the out of range: you have
pcg = F (:, 2);
which assumes that F has two or more columns, which would correspond to two or more channels. If your '1.wav' is mono then it would only have one column, F(:,1);
0 comentarios
Más respuestas (3)
poornima.a A
el 29 de En. de 2018
1 comentario
Walter Roberson
el 29 de En. de 2018
Please show your code and a complete copy of the error message.
poornima.a A
el 29 de En. de 2018
Editada: Walter Roberson
el 29 de En. de 2018
4 comentarios
Walter Roberson
el 29 de En. de 2018
Editada: Walter Roberson
el 29 de En. de 2018
You plot(t,P) . t is your time points, so it has as many entries as you have times. P, though, has as many entries as you have overlapping windows.
Just before what you had posted before as
for i = i: i + win
insert
window_times(k) = t(i);
Make sure this is before that for loop, not inside the loop.
Then at the end
plot(window_times, P)
Ver también
Categorías
Más información sobre Chebyshev 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!