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

Respuesta aceptada

Walter Roberson
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);

Más respuestas (3)

poornima.a A
poornima.a A el 29 de En. de 2018
Thank you sir and one more doubt sir,plz clarify me ,my signal length is 20324 sample,when I taking square of this signal.it shows me index out of bounds error.Give me code to do this sir

poornima.a A
poornima.a A el 29 de En. de 2018
Editada: Walter Roberson el 29 de En. de 2018
function segmentation_Shennon
close all
clear all
% Load the data file
[pcg, Fs] = audioread ('D:\phase 2 sets\audio signals\trim\normalcut.wav');
%pcg = F (:, 1);
t = 0: 1 / Fs: (length (pcg) -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 =pcg;
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)); % 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)
  4 comentarios
poornima.a A
poornima.a A el 29 de En. de 2018
thank you so mach sir its worked out well.but one more error was arises .i attached that error message,sir plz view that and give me the correction according to that error
Walter Roberson
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)

Iniciar sesión para comentar.


poornima.a A
poornima.a A el 29 de En. de 2018
sir while running my above code it shows value of p and Es are NaN .i thing error in the below code
M_Es = (mean (Es)); % mean energy of the segment
S_Es = (std (Es)); % 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)
  6 comentarios

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by