Matlab程序问题(高分求解决)Attempted to access speak1(12001); index out of bounds because numel(speak1)=12000.这是matlab的报错,下面是程序%AAWclear;close all;clc;M=10 Q=16 N=80; p=1500; speak1=wavread('01.wav');speak2=wavread('02
来源:学生作业帮助网 编辑:六六作业网 时间:2025/01/09 09:02:12
Matlab程序问题(高分求解决)Attempted to access speak1(12001); index out of bounds because numel(speak1)=12000.这是matlab的报错,下面是程序%AAWclear;close all;clc;M=10 Q=16 N=80; p=1500; speak1=wavread('01.wav');speak2=wavread('02
Matlab程序问题(高分求解决)
Attempted to access speak1(12001); index out of bounds because numel(speak1)=12000.
这是matlab的报错,下面是程序
%AAW
clear;close all;clc;
M=10
Q=16
N=80;
p=1500;
speak1=wavread('01.wav');
speak2=wavread('02.wav');
speak3=wavread('03.wav');
speak4=wavread('04.wav');
speak5=wavread('05.wav');
speak6=wavread('06.wav');
speak7=wavread('07.wav');
speak8=wavread('08.wav');
speak9=wavread('09.wav');
speak10=wavread('10.wav');
for j=1:p
for i=1:N
speak(i+80.*(j-1))=(speak1(i+80.*(j-1))+speak2(i+80.*(j-1))+speak3(i+80.*(j-1))+speak4(i+80.*(j-1))+speak5(i+80.*(j-1))+speak6(i+80.*(j-1))+speak7(i+80.*(j-1))+speak8(i+80.*(j-1))+speak9(i+80.*(j-1))+speak10(i+80.*(j-1)))./M;
end
end
wavwrite(speak,'AAW')
声音文件读入没有问题,for后面的公式是出错的地方,
Matlab程序问题(高分求解决)Attempted to access speak1(12001); index out of bounds because numel(speak1)=12000.这是matlab的报错,下面是程序%AAWclear;close all;clc;M=10 Q=16 N=80; p=1500; speak1=wavread('01.wav');speak2=wavread('02
一个问题一个问题解决
你先在for循环前定义一下矩阵:
speak=zeros(1,N+80.*(p-1));
但肯定还有问题
因为首先的你维数就不对
你length(speak1)一下,应该才12000维,而你的(N+80.*(p-1))数超过了这个数,肯定会有问题
建议你length一下speak1到10,看看他们的维数是多少