|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
%************************************************************%
%** 子函数——核函数 **
%***********************************************************%
function [K]=ker(x,y,sig)
kerRow=size(x,2);
kerColumn=size(y,2);
omega=zeros(kerRow,kerColumn);
for i=1:kerRow
for j=1:kerColumn
omega(i,j)=norm(x(:,i)-y(:,j));
end
end
K=exp(-omega.^2/(2*sig^2));
%***************************************************************
%** 截割三向力——疲劳——内插预测 **
%***************************************************************
clear;
clc;
close all;
stress_x=[2606.6 3567.6 4349.8 5029.1 5638.6 6196.6 6714.5 7200 3359.5 4801 5974.4 6993.3 7907.5 8744.6 9521.4 10250 4112.4 6034.4 7598.9 8957.5 10176 11293 12328 13299 2659 3620 4402.3 5081.5 5691 6249 6766.9 7252.4 3411.9 4853.4 6026.8 7045.7 7959.9 8797 9573.8 10302 4164.8 6086.8 7651.4 9009.9 10229 11345 12381 13352];
stress_y=[4344.3 5946 7249.7 8381.8 9397.6 10328 11191 12000 5599.1 8001.7 9957.3 11655 13179 14574 15869 17083 6854 10057 12665 14929 16961 18821 20547 22165 4431.6 6033.3 7337.1 8469.2 9485 10415 11278 12087 5686.5 8089 10045 11743 13266 14662 15956 17170 6941.3 10145 12752 15016 17048 18908 20634 22253];
stress_z=[868.85 1189.2 1449.9 1676.4 1879.5 2065.5 2238.2 2400 1119.8 1600.3 1991.5 2331.1 2635.8 2914.9 3173.8 3416.5 1370.8 2011.5 2533 2985.8 3392.1 3764.2 4109.4 4433.1 886.32 1206.7 1467.4 1693.8 1897 2083 2255.6 2417.5 1137.3 1617.8 2008.9 2348.6 2653.3 2932.3 3191.3 3434 1388.3 2028.9 2550.5 3003.3 3409.6 3781.6 4126.9 4450.6];
fatigue=[247490000 193440000 158470000 133400000 114430000 99488000 87441000 77523000 204010000 141320000 105180000 81593000 65107000 53057000 43948000 36891000 168340000 103610000 70244000 50377000 37542000 28785000 22566000 18014000 244150000 190850000 156380000 131650000 112920000 98196000 86304000 76525000 201260000 139480000 103800000 80538000 64281000 52379000 43395000 36428000 166110000 102260000 69347000 49744000 37076000 28432000 22291000 17796000];
% 数据归一化
stress_x=(stress_x-min(stress_x))/(max(stress_x)-min(stress_x))*0.85+0.15;
stress_y=(stress_y-min(stress_y))/(max(stress_y)-min(stress_y))*0.85+0.15;
stress_z=(stress_z-min(stress_z))/(max(stress_z)-min(stress_z))*0.85+0.15;
E_x=stress_x;
E_y=stress_y;
E_z=stress_z;
E_f=fatigue;
%********学习样本*******************
x1=stress_x(1:2:48);
x2=stress_y(1:2:48);
x3=stress_z(1:2:48);
xInput=[x1;x2;x3];
yOutput=fatigue(1:2:48);
%*********预测样本******************
xs1=stress_x(2:4:48);
xs2=stress_y(2:4:48);
xs3=stress_z(2:4:48);
xsInput=[xs1;xs2;xs3];
yrOutput=fatigue(2:4:48);
sig=sqrt(4.5021);
gamma=1.6236e+008;
alpha0=0.2;
%********构造 RBF 核矩阵***************
ker1=ker(xInput,xInput,sig);
for i=1:size(xInput,2)
ker1(i,i)=ker1(i,i)+1/gamma;
end
%*********LSSVM 模型训练**************
I=ones(1,size(xInput,2));
b=I*inv(ker1)*yOutput'/(I*inv(ker1)*I');
alpha=inv(ker1)*(yOutput'-b*I');
for i=1:size(alpha,1);
if abs(alpha(i))<alpha0;
alpha(i)=0;
end
end
ker2=ker(xInput,xsInput,sig);
ysOutput=alpha'*ker2+b*(ones(1,size(xsInput,2)));
%***********画图*********************
hold on;
plot(1:length(ysOutput),ysOutput,'b-');
plot(1:length(yrOutput),yrOutput,'r-.');
grid;
xlabel('序列');
ylabel('循环载荷次数/次');
title('截齿疲劳寿命曲线');
gtext('—real output');
gtext('.-predict output');
hold off;
%***********计算整体误差*********************
ave=sum(ysOutput)/length(ysOutput);
error1=sqrt(sum((yrOutput-ysOutput).^2)/sum((yrOutput-ave).^2))
%***********计算局部误差*********************
error2=sqrt(((ysOutput-yrOutput)./yrOutput).^2);
[max_error,max_ELoc]=max(error2')
[min_error,min_ELoc]=min(error2')
|
评分
-
1
查看全部评分
-
|