报错是:
??? Error using ==> plot
Vectors must be the same lengths.
程序是计算语音短时能量
程序如下
clear all; clc; close all;
%Open speech file and read the data in it
[speechSignal Fs]=wavread('E:\CoolEdit_Recording\speech.wav');
%Energy is calculated every period samples
period=50;
%4 different window lengths
winLens=[161 321 501 601];
nWindows=length(winLens);
k=0;
for i=1:nWindows
%i=1;
iWinLen=winLens(i);
k=k+1;
wHamm=hamming(iWinLen);
%Short-Time energy calculation
ienergyST=STenergy1(speechSignal,wHamm,iWinLen,period);
%plot(ienergyST)
%break
%Time in second for the graph
t=(0:length(speechSignal)-1)/Fs;
%Display results
subplot(nWindows,1,k);
delay=(iWinLen-1)/2;
plot(t(delay+1:iWinLen-period:end-delay),ienergyST);
if (k==1)
title('Short-Time energy for various Hamming windows lengths');
end
if (k==4)
xlabel('Time/sec');
end
legend(['Window length:',num2str(iWinLen),'Samples']);
end
%STenergy M函数
%计算短时能量的M文件
function f=STenergy1(speechSignal,wHamm,winLen,winOverlap)
%Framing and windowing the singnal without loops.
sigFramed=buffer2(speechSignal,winLen,winOverlap);
sigWindowed=diag(sparse(wHamm))*sigFramed;
%Calculate the short time energy
f=sum(sigWindowed.^2,1);
function out = buffer2(y, frameSize, overlap)
% buffer2: Frame blocking
% Usage: out = buffer2(y, frameSize, overlap)
% This is almost the same as "buffer" except that there is no leading/trailing zeros
% Roger Jang, 20010908
if nargin<3, overlap=0; end
if nargin<2, frameSize=256; end
y = y(:);
step = frameSize-overlap;
frameCount = floor((length(y)-overlap)/step);
out = zeros(frameSize, frameCount);
for i=1:frameCount,
startIndex = (i-1)*step+1;
out(:, i) = y(startIndex:(startIndex+frameSize-1));
end
请问要怎么办?急!在线等!
??? Error using ==> plot
Vectors must be the same lengths.
程序是计算语音短时能量
程序如下
clear all; clc; close all;
%Open speech file and read the data in it
[speechSignal Fs]=wavread('E:\CoolEdit_Recording\speech.wav');
%Energy is calculated every period samples
period=50;
%4 different window lengths
winLens=[161 321 501 601];
nWindows=length(winLens);
k=0;
for i=1:nWindows
%i=1;
iWinLen=winLens(i);
k=k+1;
wHamm=hamming(iWinLen);
%Short-Time energy calculation
ienergyST=STenergy1(speechSignal,wHamm,iWinLen,period);
%plot(ienergyST)
%break
%Time in second for the graph
t=(0:length(speechSignal)-1)/Fs;
%Display results
subplot(nWindows,1,k);
delay=(iWinLen-1)/2;
plot(t(delay+1:iWinLen-period:end-delay),ienergyST);
if (k==1)
title('Short-Time energy for various Hamming windows lengths');
end
if (k==4)
xlabel('Time/sec');
end
legend(['Window length:',num2str(iWinLen),'Samples']);
end
%STenergy M函数
%计算短时能量的M文件
function f=STenergy1(speechSignal,wHamm,winLen,winOverlap)
%Framing and windowing the singnal without loops.
sigFramed=buffer2(speechSignal,winLen,winOverlap);
sigWindowed=diag(sparse(wHamm))*sigFramed;
%Calculate the short time energy
f=sum(sigWindowed.^2,1);
function out = buffer2(y, frameSize, overlap)
% buffer2: Frame blocking
% Usage: out = buffer2(y, frameSize, overlap)
% This is almost the same as "buffer" except that there is no leading/trailing zeros
% Roger Jang, 20010908
if nargin<3, overlap=0; end
if nargin<2, frameSize=256; end
y = y(:);
step = frameSize-overlap;
frameCount = floor((length(y)-overlap)/step);
out = zeros(frameSize, frameCount);
for i=1:frameCount,
startIndex = (i-1)*step+1;
out(:, i) = y(startIndex:(startIndex+frameSize-1));
end
请问要怎么办?急!在线等!