相关程序分类问题,如下.da1= [0.880138 0.763333 0.805714];da2= [0.742345 0.644615 0.848571];da3= [0.776414 0.673846 0.788571];da4= [0.747862 0.649231 0.782857];da5= [0.827034 0.717692 0.788571];da6= [0.750207 0.651282 0.785714];da7= [0.827034
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/17 11:32:22
相关程序分类问题,如下.da1= [0.880138 0.763333 0.805714];da2= [0.742345 0.644615 0.848571];da3= [0.776414 0.673846 0.788571];da4= [0.747862 0.649231 0.782857];da5= [0.827034 0.717692 0.788571];da6= [0.750207 0.651282 0.785714];da7= [0.827034
相关程序分类问题,如下.
da1= [0.880138 0.763333 0.805714];
da2= [0.742345 0.644615 0.848571];
da3= [0.776414 0.673846 0.788571];
da4= [0.747862 0.649231 0.782857];
da5= [0.827034 0.717692 0.788571];
da6= [0.750207 0.651282 0.785714];
da7= [0.827034 0.717692 0.800000];
da8= [0.892276 0.773846 0.814286];
da9= [0.891586 0.773333 0.831429];
da10= [0.928000 0.804615 0.948571];
da11= [0.714897 0.620769 0.825714];
da12= [0.819448 0.711026 0.717143];
da13= [0.793103 0.688205 0.711429];
da14= [0.719034 0.624359 0.722857];
da15= [0.739448 0.642051 0.751429];
da16= [0.931586 0.807692 0.822857];
da17= [0.854483 0.741282 0.848571];
da18= [0.705517 0.612821 0.7 ];
da19= [0.754069 0.654615 0.734286];
da20= [0.722897 0.627692 0.685714];
A=[da16' da17' da18' da19' da20'];
B=[da1' da2' da3' da4' da5' da6' da7' da8' da9' da10' da11' da12' da13' da14' da15'];
m=15;
g=5;
dist=zeros(g,m);
c1=zeros(1,5);
for i=1:g
for j=1:m
dist(i,j)=sum((A(:,i)-B(:,j)).^2);
end
end
dist
[distsort index]=sort(dist(1,:))
for i=1:15
c(i)=fix((index(i)-1)/3)+1;
end
c
for i=1:3
for j=1:5
k=c(i)==j
if k
c1(j)=c1(j)+1;
end
end
c1
运行后结果如下
dist =
0.0049 0.0631 0.0432 0.0605 0.0202 0.0587 0.0196 0.0028 0.0029 0.0158 0.0819 0.0331 0.0459 0.0888 0.0695
0.0030 0.0219 0.0142 0.0242 0.0049 0.0229 0.0037 0.0037 0.0027 0.0194 0.0345 0.0194 0.0254 0.0478 0.0325
0.0643 0.0244 0.0166 0.0100 0.0336 0.0108 0.0358 0.0739 0.0777 0.1481 0.0160 0.0229 0.0135 0.0008 0.0047
0.0328 0.0133 0.0038 0.0024 0.0122 0.0027 0.0136 0.0397 0.0424 0.0987 0.0110 0.0078 0.0032 0.0023 0.0007
0.0575 0.0272 0.0156 0.0105 0.0295 0.0113 0.0320 0.0666 0.0709 0.1425 0.0197 0.0173 0.0093 0.0014 0.0048
distsort =
0.0028 0.0029 0.0049 0.0158 0.0196 0.0202 0.0331 0.0432 0.0459 0.0587 0.0605 0.0631 0.0695 0.0819 0.0888
index =
8 9 1 10 7 5 12 3 13 6 4 2 15 11 14
c =
3 3 1 4 3 2 4 1 5 2 2 1 5 4 5
da16对应待测的da8 da9 da1,类别分别为331,那么就属于第3类,da17对应的432,那么为0,da18对应的415,也为0,da19对应的221,那么就属于第2类,da20对应的545,那么就属于第5类,我想知道这一段程序该怎么写,
相关程序分类问题,如下.da1= [0.880138 0.763333 0.805714];da2= [0.742345 0.644615 0.848571];da3= [0.776414 0.673846 0.788571];da4= [0.747862 0.649231 0.782857];da5= [0.827034 0.717692 0.788571];da6= [0.750207 0.651282 0.785714];da7= [0.827034
da1= [0.880138 0.763333 0.805714];
da2= [0.742345 0.644615 0.848571];
da3= [0.776414 0.673846 0.788571];
da4= [0.747862 0.649231 0.782857];
da5= [0.827034 0.717692 0.788571];
da6= [0.750207 0.651282 0.785714];
da7= [0.827034 0.717692 0.800000];
da8= [0.892276 0.773846 0.814286];
da9= [0.891586 0.773333 0.831429];
da10= [0.928000 0.804615 0.948571];
da11= [0.714897 0.620769 0.825714];
da12= [0.819448 0.711026 0.717143];
da13= [0.793103 0.688205 0.711429];
da14= [0.719034 0.624359 0.722857];
da15= [0.739448 0.642051 0.751429];
da16= [0.931586 0.807692 0.822857];
da17= [0.854483 0.741282 0.848571];
da18= [0.705517 0.612821 0.7 ];
da19= [0.754069 0.654615 0.734286];
da20= [0.722897 0.627692 0.685714];
A=[da16' da17' da18' da19' da20'];
B=[da1' da2' da3' da4' da5' da6' da7' da8' da9' da10' da11' da12' da13' da14' da15'];
m=15;
g=5;
dist=zeros(g,m);
distsort=zeros(g,m);
index=zeros(g,m);
for i=1:g
for j=1:m
dist(i,j)=sum((A(:,i)-B(:,j)).^2);
end
[distsort(i,:) index(i,:)]=sort(dist(i,:));
a=fix((index(i,1:3)-1)/3+1);
b=[0 sort(unique(a))];
c=hist(a,b);
lei=b(c==max(c));
str1=strcat('a',num2str(i+15),'属于第',num2str(lei),'类')
end