不知道为什么报这样的错:Attempted to access e(10,:); index out of bounds

问题描述:

不知道为什么报这样的错:Attempted to access e(10,:); index out of bounds because size(e)=[0,256]
fid=fopen('test1.txt','rt'); %打开文件
y=fscanf(fid,'%f'); %读数据
e=fra(256,128,y); %对y分帧,帧长256,帧移128
ee=e(10,:); %选取第10帧
subplot(211) %画第一个子图
ee1=ee/max(ee); %幅值归一化
plot(ee1) %画波形
xlabel('样点数') %横坐标名称
ylabel('幅度') %纵坐标名称
title ('原始语音') %文字标注
axis([0,256,-1.5,1.5]) %限定横纵坐标范围
% 矩形窗傅立叶变换
r=fft(ee,1024); %对信号ee进行1024点傅立叶变换
r1=abs(r); %对r取绝对值 r1表示频谱的幅度值
r1=r1/max(r1); %幅值归一化
yuanlai=20*log10(r1); %对归一化幅值取对数
signal(1:256)=yuanlai(1:256); %取256个点,目的是画图的时候,维数一致
pinlv=(0:1:255)*8000/512; %点和频率的对应关系
subplot(212) %画第二个子图
plot(pinlv,signal); %画幅值特性图
xlabel('f/Hz') %横坐标名称
ylabel('对数幅度/dB') %纵坐标名称
title ('加矩形窗时语音谱') %文字标注
axis([0,4000,-80,15]) %限定横纵坐标范围
1个回答 分类:综合 2014-11-19

问题解答:

我来补答
ee=e(10,:); %选取第10帧
长度不够,数组越界
十大低级错误之首
 
 
展开全文阅读
剩余:2000