if ou(i)==4
t4=[0,5,30,60,90,120,180,240];
for j=1:8;
dc4(i,j)=(wholemydata(:,i)-jc4(:,j))'*(wholemydata(:,i)-jc4(:,j));
end
[a,b]=min(dc4(i,:));
ds=dc4(i,[1:b-1,b+1:8]);
[c,d]=min(ds);
if d>=b
d=d+1;
end
t(i)=t4(b)*a/(a+c)+t4(d)*c/(a+c);
clear ds
end
end
%交叉检验
count1(1:4)=0;
count2(1:4)=0;
count3(1:4)=0;
count4(1:4)=0;
for i=98:-1:1
cdata1=wholedata1(:,[1:i-1,i+1:98]);
cdata2=wholedata2;
cdata3=wholedata3;
cdata4=wholedata4;
ddata=wholedata1(:,i);
checkout1(i,:)=L_long(cdata1,cdata2,cdata3,cdata4,ddata);
if checkout1(i,:)==1
count1(1)=count1(1)+1;
elseif checkout1(i,:)==2
count1(2)=count1(2)+1;
elseif checkout1(i,:)==3
count1(3)=count1(3)+1;
else
count1(4)=count1(4)+1;
end
end
for i=66:-1:1
cdata1=wholedata1;
cdata2=wholedata2(:,[1:i-1,i+1:66]);
cdata3=wholedata3;
cdata4=wholedata4;
ddata=wholedata2(:,i);
checkout2(i,:)=L_long(cdata1,cdata2,cdata3,cdata4,ddata);
if checkout2(i,:)==1
count2(1)=count1(1)+1;
elseif checkout2(i,:)==2
count2(2)=count1(2)+1;
elseif checkout2(i,:)==3
count2(3)=count1(3)+1;
else
count2(4)=count1(4)+1;
end
end
for i=88:-1:1
cdata1=wholedata1;
cdata2=wholedata2;
cdata3=wholedata3(:,[1:i-1,i+1:88]);
cdata4=wholedata4;
ddata=wholedata3(:,i);
checkout3(i,:)=L_long(cdata1,cdata2,cdata3,cdata4,ddata);
if checkout3(i,:)==1
count3(1)=count1(1)+1;
elseif checkout3(i,:)==2
count3(2)=count1(2)+1;
elseif checkout3(i,:)==3
count3(3)=count1(3)+1;
else
count3(4)=count1(4)+1;
end
end
for i=88:-1:1
cdata1=wholedata1;
cdata2=wholedata2;
cdata3=wholedata3;
cdata4=wholedata4(:,[1:i-1,i+1:88]);
ddata=wholedata4(:,i);
checkout4(i,:)=L_long(cdata1,cdata2,cdata3,cdata4,ddata);
if checkout4(i,:)==1
count4(1)=count4(1)+1;
elseif checkout4(i,:)==2
count4(2)=count4(2)+1;
elseif checkout4(i,:)==3
count4(3)=count4(3)+1;
else
count4(4)=count4(4)+1;
end
end
[count1;count2;count3;count4]
function ff=L_long(wholedata1,wholedata2,wholedata3,wholedata4,wholemydata) %用兰氏距离判断类别
u1=mean(wholedata1')';
u2=mean(wholedata2')';
u3=mean(wholedata3')';
u4=mean(wholedata4')';
long1=0;
long2=0;
long3=0;
long4=0;
for i=1:1
long1(i)=sum(abs(wholemydata(:,i)-u1)./(wholemydata(:,i)+u1))
long2(i)=sum(abs(wholemydata(:,i)-u2)./(wholemydata(:,i)+u2));
www.751com.cn
[type(i),ff(i)]=min([long1(i),long2(i),long3(i),long4(i)]);
end
function kk=ou_long(wholedata1,wholedata2,wholedata3,wholedata4,wholemydata) %用欧氏距离判断类别
long1=0;
long2=0;
long3=0;
long4=0;
u1=mean(wholedata1')';
u2=mean(wholedata2')';
u3=mean(wholedata3')';
u4=mean(wholedata4')';
for i=1:1
long1(i)=(wholemydata(:,i)-u1)'*(wholemydata(:,i)-u1);
long2(i)=(wholemydata(:,i)-u2)'*(wholemydata(:,i)-u2);
long3(i)=(wholemydata(:,i)-u3)'*(wholemydata(:,i)-u3);
long4(i)=(wholemydata(:,i)-u4)'*(wholemydata(:,i)-u4);
end
for i=1:1
[type(i),kk(i)]=min([long1(i),long2(i),long3(i),long4(i)]);
end