matlab 数组下标可能为负怎么办Equ1 = 0; %初始化E = 0;syms a; for j0 = 1:10a(1,j0) = sym(['a',num2str(j0)]);endfor n = 1:20 %循环生成e和Efor k0 = 1:10Equ1 = Equ1 + a(k0) * x(n-k0); %%%%%%%%%在这个地方n-k0有可能为负值,endE
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/16 03:20:48
matlab 数组下标可能为负怎么办Equ1 = 0; %初始化E = 0;syms a; for j0 = 1:10a(1,j0) = sym(['a',num2str(j0)]);endfor n = 1:20 %循环生成e和Efor k0 = 1:10Equ1 = Equ1 + a(k0) * x(n-k0); %%%%%%%%%在这个地方n-k0有可能为负值,endE
matlab 数组下标可能为负怎么办
Equ1 = 0; %初始化
E = 0;
syms a;
for j0 = 1:10
a(1,j0) = sym(['a',num2str(j0)]);
end
for n = 1:20 %循环生成e和E
for k0 = 1:10
Equ1 = Equ1 + a(k0) * x(n-k0); %%%%%%%%%在这个地方n-k0有可能为负值,
end
E = E + (x(n) - Equ1)^2;
e(n) = x(n) - Equ1;
end
%能不能把下标为负值的时候令x的值为0呢?
matlab 数组下标可能为负怎么办Equ1 = 0; %初始化E = 0;syms a; for j0 = 1:10a(1,j0) = sym(['a',num2str(j0)]);endfor n = 1:20 %循环生成e和Efor k0 = 1:10Equ1 = Equ1 + a(k0) * x(n-k0); %%%%%%%%%在这个地方n-k0有可能为负值,endE
这样改:
for n = 1: 20
for k0 = 1: 10
a=n-k0;
x(a