帮忙改个matlab的程序a=ones(8);a(1,2)=3;a(1,3)=4;a(1,4)=5;a(1,5)=6;a(1,6)=7;a(1,7)=8;a(1,8)=9;a(2,3)=3;a(2,4)=4;a(2,5)=5;a(2,6)=6;a(2,7)=7;a(2,8)=8;a(3,4)=3;a(3,5)=4;a(3,6)=5;a(3,7)=6;a(3,8)=7;a(4,5)=3;a(4,6)=4;a(4,7)=5;a(4,8)=6;a(5,6)=3;a(5,7)
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/18 16:43:50
帮忙改个matlab的程序a=ones(8);a(1,2)=3;a(1,3)=4;a(1,4)=5;a(1,5)=6;a(1,6)=7;a(1,7)=8;a(1,8)=9;a(2,3)=3;a(2,4)=4;a(2,5)=5;a(2,6)=6;a(2,7)=7;a(2,8)=8;a(3,4)=3;a(3,5)=4;a(3,6)=5;a(3,7)=6;a(3,8)=7;a(4,5)=3;a(4,6)=4;a(4,7)=5;a(4,8)=6;a(5,6)=3;a(5,7)
帮忙改个matlab的程序
a=ones(8);
a(1,2)=3;a(1,3)=4;a(1,4)=5;a(1,5)=6;a(1,6)=7;a(1,7)=8;a(1,8)=9;
a(2,3)=3;a(2,4)=4;a(2,5)=5;a(2,6)=6;a(2,7)=7;a(2,8)=8;
a(3,4)=3;a(3,5)=4;a(3,6)=5;a(3,7)=6;a(3,8)=7;
a(4,5)=3;a(4,6)=4;a(4,7)=5;a(4,8)=6;
a(5,6)=3;a(5,7)=4;a(5,8)=5;
a(6,7)=3;a(6,8)=4;
a(7,8)=3;
for j=1:8
c(j)=sum(a(:,j))/40;%求均值
z(j)=var(a(:,j));%求方差
end
for j=1:8
for i=1:40
x(i,j)=(a(i,j)-c(j))/sqrt(z(j));
end
end
f=cov(x);
[v,d]=eig(f);
h=0;g=0;
for m=1:8
g=g+d(m,m);
end
for n=1:8
if d(n,n)>1
h=h+d(n,n);
end
end
k=h/g;
F1=x*v(:,8);
F2=x*v(:,7);
F=d(8,8)/(d(8,8)+d(7,7))*F1+d(7,7)/(d(8,8)+d(7,7))*F2;
[y,q]=sort(F,'descend');
y'
q'
Warning:Divide by zero.
Warning:Divide by zero.
Warning:Divide by zero.
Warning:Divide by zero.
Warning:Divide by zero.
Warning:Divide by zero.
Warning:Divide by zero.
Warning:Divide by zero.
Index exceeds matrix dimensions.
帮忙改个matlab的程序a=ones(8);a(1,2)=3;a(1,3)=4;a(1,4)=5;a(1,5)=6;a(1,6)=7;a(1,7)=8;a(1,8)=9;a(2,3)=3;a(2,4)=4;a(2,5)=5;a(2,6)=6;a(2,7)=7;a(2,8)=8;a(3,4)=3;a(3,5)=4;a(3,6)=5;a(3,7)=6;a(3,8)=7;a(4,5)=3;a(4,6)=4;a(4,7)=5;a(4,8)=6;a(5,6)=3;a(5,7)
for i=1:40
x(i,j)=(a(i,j)-c(j))/sqrt(z(j));
end
你的i没有40个啊
而且你的z(1,:)=0