|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
clc
clear
load guzhangshuju.mat;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% aa=eye(6,6);
% for i=1:6
% for j=1:5
% mubiao11(j+5*(i-1),:)=aa(i,:);
% end
% end
%%对输入样本进行归一化处理;
hehehe=ans';
% hehehe=[tftransi;tfinterr;tfharmonic;tnsag; tfspike; tfswell;tfnotch];
max1=max(hehehe);
% hehehe=[hehehe(:,1)/max1(1) hehehe(:,2)/max1(2) hehehe(:,3)/max1(3) hehehe(:,4)/max1(4) hehehe(:,5)/max1(5) hehehe(:,6)/max1(6) ];
for i=1:100
hehehe(:,i)= hehehe(:,i)/max1(i);
end
hehehe=hehehe';
% %%用神经网络分类识别
pp=[hehehe([1:5],:); hehehe([11:15],:);hehehe([21:25],:);hehehe([61:65],:);hehehe([71:75],:);hehehe([81:85],:);hehehe([91:95],:)];
jiance=[hehehe([6:10],:);hehehe([16:20],:);hehehe([26:30],:); hehehe([66:70],:);hehehe([76:80],:);hehehe([86:90],:);hehehe([96:100],:)];
%%用BP网络进行训练;
%net=newff(minmax(pp'),[22,7],{'tansig','purelin'});
%net.trainParam.epochs=75;
%net.trainParam.goal=0.001;
%net=train(net,pp',mubiao11');
%tt=sim(net,pp');
%%%%%%%%%%%%%%%%%%%%%%%%%%
% spread=12;
% net=newrbe(pp',mubiao11',spread);
% %%样本的检测;
% tt=sim(net,jiance');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%svm进行识别
%%用6个SVM对信号进行分类
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%第一个svm1
X1=pp;
Y1=[ones(1,5) -ones(1,30)];
gam=30;
sig2=2;
[alpha1,b1]=trainlssvm({X1,Y1','c',gam,sig2});
%%第二个svm2
X2=[hehehe([11:15],:);hehehe([21:25],:);hehehe([61:65],:);hehehe([71:75],:);hehehe([81:85],:);hehehe([91:95],:)];
Y2=[ones(1,5) -ones(1,25)];
[alpha2,b2]=trainlssvm({X2,Y2','c',gam,sig2});
%%第三svm3
X3=[hehehe([21:25],:);hehehe([61:65],:);hehehe([71:75],:);hehehe([81:85],:);hehehe([91:95],:)];
Y3=[ones(1,5) -ones(1,20)];
[alpha3,b3]=trainlssvm({X3,Y3','c',gam,sig2});
%%第四个svm4
X4=[hehehe([61:65],:);hehehe([71:75],:);hehehe([81:85],:);hehehe([91:95],:)];
Y4=[ones(1,5) -ones(1,15)];
[alpha4,b4]=trainlssvm({X4,Y4','c',gam,sig2});
%%第五个svm5
X5=[hehehe([71:75],:);hehehe([81:85],:);hehehe([91:95],:)];
Y5=[ones(1,5) -ones(1,10)];
[alpha5,b5]=trainlssvm({X5,Y5','c',gam,sig2});
%%第六个svm6
X6=[hehehe([81:85],:);hehehe([91:95],:)];
Y6=[ones(1,5) -ones(1,5)];
[alpha6,b6]=trainlssvm({X6,Y6','c',gam,sig2});
% %%第七个svm6
% X6=[hehehe([61:65],:);hehehe([71:75],:);hehehe([81:85],:);hehehe([91:95],:)];
% Y6=[ones(1,5) -ones(1,15)];
% [alpha6,b6]=trainlssvm({X6,Y6','c',gam,sig2});
% %%第八个svm6
% X6=[hehehe([71:75],:);hehehe([81:85],:);hehehe([91:95],:)];
% Y6=[ones(1,5) -ones(1,10)];
% [alpha6,b6]=trainlssvm({X6,Y6','c',gam,sig2});
% %%第九个svm6
% X6=[hehehe([81:85],:);hehehe([91:95],:)];$
% Y6=[ones(1,5) -ones(1,5)];
% [alpha6,b6]=trainlssvm({X6,Y6','c',gam,sig2});
%将训练好的svm用于样本的检测
Yhs1=simlssvm({X1,Y1','c',gam,sig2},{alpha1,b1},jiance);
%%将非正的用svm2检测;该程序要查看后才能确定下一检测的个数;
Yhs2=simlssvm({X2,Y2','c',gam,sig2},{alpha2,b2},jiance([6:35],:));
%%将非正的用svm3检测;该程序要查看后才能确定下一检测的个数;
Yhs3=simlssvm({X3,Y3','c',gam,sig2},{alpha3,b3},jiance([11:35],:));
%%将非正的用svm3检测;该程序要查看后才能确定下一检测的个数;
Yhs4=simlssvm({X4,Y4','c',gam,sig2},{alpha4,b4},jiance([16:35],:));
%%将非正的用svm3检测;该程序要查看后才能确定下一检测的个数;
Yhs5=simlssvm({X5,Y5','c',gam,sig2},{alpha5,b5},jiance([21:35],:));
%%将非正的用svm3检测;该程序要查看后才能确定下一检测的个数;
Yhs6=simlssvm({X6,Y6','c',gam,sig2},{alpha6,b6},jiance([26:35],:)); |
|