马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
我找到的一个关于熵函数的程序,
??? Undefined command/function 'frameEnergy'.
Error in ==> shangFunc at 19
en=frameEnergy(y);请问frameEnergy这个程序谁有
function hh=shangFunc(sig,fs,windowsize,overlap);
if nargin==0
sig=wavread('D:\Program Files\MATLAB712\work\0a.wav');
sig=sig(2:length(sig));
end
if nargin<4
overlap=128;
end
if nargin<3
windowsize=256;
end
if nargin<2
fs=8000;
end
N=windowsize;
k=overlap;
y=buffer(sig,N,k);
fNum=size(y,2);
en=frameEnergy(y);
time=((0:fNum-1)*(N-k)+0.5*N)/fs;
subplot(311);plot((1:length(sig))/fs, sig);
subplot(312);plot(time,en,'r');axis tight
% 求熵的过程;
% 每帧只有一个值;
%
s=abs(y); % 求绝对值
h=[];
for i=1:fNum,
c=s(:,i); %取帧
d=sum(c); %求和
if d~=0
dk=c/d; %求相对值
else
dk=0;
end
hf=-sum(log10(dk.^dk))-log10(d); %求对数熵,且第一项有概率密度函数特征
% 第二项为添加项。代表区间内信号大小变化大,能量也大,
% 重要性也大。没有声音时或噪音时,hf大些,浊音时小些;
h=[h;hf];
end
hh=h';
%=================================
Shanglevel=0.8;
soundIndex = find(hh<=Shanglevel);
sound = [];
k=1;
sound(k).begin = soundIndex(1);
for i=2:length(soundIndex)-1,
if soundIndex(i+1)-soundIndex(i)>1,% 连续的两帧以上为满足能量最低条件。
sound(k).end = soundIndex(i);
sound(k+1).begin = soundIndex(i+1);
k = k+1;
end
end
sound(k).end = soundIndex(end);
if length(sound) ~=0,
for i=1:length(sound),
out(i).begin = (sound(i).begin-1)*(windowsize-overlap)+1;
out(i).end = (sound(i).end)*(windowsize-overlap)+overlap;
end
else
out = [];
end;
subplot(313);plot(time,hh);axis([-inf inf 0 inf]);
line([min(time), max(time)], Shanglevel*[1 1], 'color', 'c');
yBound = [0 max(hh)];
subplot(313);
for i=1:length(sound),
line(sound(i).begin*(windowsize-overlap)/fs*[1,1], yBound, 'color', 'r');
line( sound(i).end*(windowsize-overlap)/fs*[1,1], yBound, 'color', 'g');
end
subplot(311);yBound=[-max(sig) max(sig)];
for i=1:length(sound),
line(sound(i).begin*(windowsize-overlap)/fs*[1,1], yBound, 'color', 'r');
line( sound(i).end*(windowsize-overlap)/fs*[1,1], yBound, 'color', 'g');
end |