# 神经网络预测应力应变-单轴实验

1、内容简介

492-可以交流、咨询、答疑

2、内容说明

clear
clc
close all
%% ------------ 提取数据 ------------
% 单轴实验.xlsx

% 5MPa.xlsx

% 10MPa.xlsx

% 15MPa.xlsx

%% 数据融合处理，生成BP需要的数据量
pressure = [];
fibre_length = [];
volume_percentage = [];
x = [];
y = [];
%------------------单轴数据------------------------------------------
pressure = [pressure zeros(length(data_C50_0),1)];
fibre_length = [fibre_length zeros(length(data_C50_0),1)];
volume_percentage = [volume_percentage zeros(length(data_C50_0),1)];
x = [x data_C50_0(:,1)];
y = [y data_C50_0(:,2)];

pressure = [pressure; zeros(length(data_6_02_0),1)];
fibre_length = [fibre_length; 6*ones(length(data_6_02_0),1)];
volume_percentage = [volume_percentage; 0.2*ones(length(data_6_02_0),1)];
x = [x; data_6_02_0(:,1)];
y = [y; data_6_02_0(:,2)];
pressure = [pressure; zeros(length(data_6_04_0),1)];
fibre_length = [fibre_length; 6*ones(length(data_6_04_0),1)];
volume_percentage = [volume_percentage; 0.4*ones(length(data_6_04_0),1)];
x = [x; data_6_04_0(:,1)];
y = [y; data_6_04_0(:,2)];
pressure = [pressure; zeros(length(data_6_06_0),1)];
fibre_length = [fibre_length; 6*ones(length(data_6_06_0),1)];
volume_percentage = [volume_percentage; 0.6*ones(length(data_6_06_0),1)];
x = [x; data_6_06_0(:,1)];
y = [y; data_6_06_0(:,2)];

pressure = [pressure; zeros(length(data_12_02_0),1)];
fibre_length = [fibre_length; 12*ones(length(data_12_02_0),1)];
volume_percentage = [volume_percentage; 0.2*ones(length(data_12_02_0),1)];
x = [x; data_12_02_0(:,1)];
y = [y; data_12_02_0(:,2)];
pressure = [pressure; zeros(length(data_12_04_0),1)];
fibre_length = [fibre_length; 12*ones(length(data_12_04_0),1)];
volume_percentage = [volume_percentage; 0.4*ones(length(data_12_04_0),1)];
x = [x; data_12_04_0(:,1)];
y = [y; data_12_04_0(:,2)];
pressure = [pressure; zeros(length(data_12_06_0),1)];
fibre_length = [fibre_length; 12*ones(length(data_12_06_0),1)];
volume_percentage = [volume_percentage; 0.6*ones(length(data_12_06_0),1)];
x = [x; data_12_06_0(:,1)];
y = [y; data_12_06_0(:,2)];

pressure = [pressure; zeros(length(data_18_02_0),1)];
fibre_length = [fibre_length; 18*ones(length(data_18_02_0),1)];
volume_percentage = [volume_percentage; 0.2*ones(length(data_18_02_0),1)];
x = [x; data_18_02_0(:,1)];
y = [y; data_18_02_0(:,2)];
pressure = [pressure; zeros(length(data_18_04_0),1)];
fibre_length = [fibre_length; 18*ones(length(data_18_04_0),1)];
volume_percentage = [volume_percentage; 0.4*ones(length(data_18_04_0),1)];
x = [x; data_18_04_0(:,1)];
y = [y; data_18_04_0(:,2)];
pressure = [pressure; zeros(length(data_18_06_0),1)];
fibre_length = [fibre_length; 18*ones(length(data_18_06_0),1)];
volume_percentage = [volume_percentage; 0.6*ones(length(data_18_06_0),1)];
x = [x; data_18_06_0(:,1)];
y = [y; data_18_06_0(:,2)];

%------------------5MPa数据------------------------------------------
pressure = [pressure; 5*ones(length(data_C50_5),1)];
fibre_length = [fibre_length; zeros(length(data_C50_5),1)];
volume_percentage = [volume_percentage; zeros(length(data_C50_5),1)];
x = [x; data_C50_5(:,1)];
y = [y; data_C50_5(:,2)];

pressure = [pressure; 5*ones(length(data_6_02_5),1)];
fibre_length = [fibre_length; 6*ones(length(data_6_02_5),1)];
volume_percentage = [volume_percentage; 0.2*ones(length(data_6_02_5),1)];
x = [x; data_6_02_5(:,1)];
y = [y; data_6_02_5(:,2)];
pressure = [pressure; 5*ones(length(data_6_04_5),1)];
fibre_length = [fibre_length; 6*ones(length(data_6_04_5),1)];
volume_percentage = [volume_percentage; 0.4*ones(length(data_6_04_5),1)];
x = [x; data_6_04_5(:,1)];
y = [y; data_6_04_5(:,2)];
pressure = [pressure; 5*ones(length(data_6_06_5),1)];
fibre_length = [fibre_length; 6*ones(length(data_6_06_5),1)];
volume_percentage = [volume_percentage; 0.6*ones(length(data_6_06_5),1)];
x = [x; data_6_06_5(:,1)];
y = [y; data_6_06_5(:,2)];

pressure = [pressure; 5*ones(length(data_12_02_5),1)];
fibre_length = [fibre_length; 12*ones(length(data_12_02_5),1)];
volume_percentage = [volume_percentage; 0.2*ones(length(data_12_02_5),1)];
x = [x; data_12_02_5(:,1)];
y = [y; data_12_02_5(:,2)];
pressure = [pressure; 5*ones(length(data_12_04_5),1)];
fibre_length = [fibre_length; 12*ones(length(data_12_04_5),1)];
volume_percentage = [volume_percentage; 0.4*ones(length(data_12_04_5),1)];
x = [x; data_12_04_5(:,1)];
y = [y; data_12_04_5(:,2)];
pressure = [pressure; 5*ones(length(data_12_06_5),1)];
fibre_length = [fibre_length; 12*ones(length(data_12_06_5),1)];
volume_percentage = [volume_percentage; 0.6*ones(length(data_12_06_5),1)];
x = [x; data_12_06_5(:,1)];
y = [y; data_12_06_5(:,2)];

pressure = [pressure; 5*ones(length(data_18_02_5),1)];
fibre_length = [fibre_length; 18*ones(length(data_18_02_5),1)];
volume_percentage = [volume_percentage; 0.2*ones(length(data_18_02_5),1)];
x = [x; data_18_02_5(:,1)];
y = [y; data_18_02_5(:,2)];
pressure = [pressure; 5*ones(length(data_18_04_5),1)];
fibre_length = [fibre_length; 18*ones(length(data_18_04_5),1)];
volume_percentage = [volume_percentage; 0.4*ones(length(data_18_04_5),1)];
x = [x; data_18_04_5(:,1)];
y = [y; data_18_04_5(:,2)];
pressure = [pressure; 5*ones(length(data_18_06_5),1)];
fibre_length = [fibre_length; 18*ones(length(data_18_06_5),1)];
volume_percentage = [volume_percentage; 0.6*ones(length(data_18_06_5),1)];
x = [x; data_18_06_5(:,1)];
y = [y; data_18_06_5(:,2)];

%------------------10MPa数据------------------------------------------
pressure = [pressure; 10*ones(length(data_C50_10),1)];
fibre_length = [fibre_length; zeros(length(data_C50_10),1)];
volume_percentage = [volume_percentage; zeros(length(data_C50_10),1)];
x = [x; data_C50_10(:,1)];
y = [y; data_C50_10(:,2)];

pressure = [pressure; 10*ones(length(data_6_02_10),1)];
fibre_length = [fibre_length; 6*ones(length(data_6_02_10),1)];
volume_percentage = [volume_percentage; 0.2*ones(length(data_6_02_10),1)];
x = [x; data_6_02_10(:,1)];
y = [y; data_6_02_10(:,2)];
pressure = [pressure; 10*ones(length(data_6_04_10),1)];
fibre_length = [fibre_length; 6*ones(length(data_6_04_10),1)];
volume_percentage = [volume_percentage; 0.4*ones(length(data_6_04_10),1)];
x = [x; data_6_04_10(:,1)];
y = [y; data_6_04_10(:,2)];
pressure = [pressure; 10*ones(length(data_6_06_10),1)];
fibre_length = [fibre_length; 6*ones(length(data_6_06_10),1)];
volume_percentage = [volume_percentage; 0.6*ones(length(data_6_06_10),1)];
x = [x; data_6_06_10(:,1)];
y = [y; data_6_06_10(:,2)];

pressure = [pressure; 10*ones(length(data_12_02_10),1)];
fibre_length = [fibre_length; 12*ones(length(data_12_02_10),1)];
volume_percentage = [volume_percentage; 0.2*ones(length(data_12_02_10),1)];
x = [x; data_12_02_10(:,1)];
y = [y; data_12_02_10(:,2)];
pressure = [pressure; 10*ones(length(data_12_04_10),1)];
fibre_length = [fibre_length; 12*ones(length(data_12_04_10),1)];
volume_percentage = [volume_percentage; 0.4*ones(length(data_12_04_10),1)];
x = [x; data_12_04_10(:,1)];
y = [y; data_12_04_10(:,2)];
pressure = [pressure; 10*ones(length(data_12_06_10),1)];
fibre_length = [fibre_length; 12*ones(length(data_12_06_10),1)];
volume_percentage = [volume_percentage; 0.6*ones(length(data_12_06_10),1)];
x = [x; data_12_06_10(:,1)];
y = [y; data_12_06_10(:,2)];

pressure = [pressure; 10*ones(length(data_18_02_10),1)];
fibre_length = [fibre_length; 18*ones(length(data_18_02_10),1)];
volume_percentage = [volume_percentage; 0.2*ones(length(data_18_02_10),1)];
x = [x; data_18_02_10(:,1)];
y = [y; data_18_02_10(:,2)];
pressure = [pressure; 10*ones(length(data_18_04_10),1)];
fibre_length = [fibre_length; 18*ones(length(data_18_04_10),1)];
volume_percentage = [volume_percentage; 0.4*ones(length(data_18_04_10),1)];
x = [x; data_18_04_10(:,1)];
y = [y; data_18_04_10(:,2)];
pressure = [pressure; 10*ones(length(data_18_06_10),1)];
fibre_length = [fibre_length; 18*ones(length(data_18_06_10),1)];
volume_percentage = [volume_percentage; 0.6*ones(length(data_18_06_10),1)];
x = [x; data_18_06_10(:,1)];
y = [y; data_18_06_10(:,2)];

%------------------15MPa数据------------------------------------------
pressure = [pressure; 15*ones(length(data_C50_15),1)];
fibre_length = [fibre_length; zeros(length(data_C50_15),1)];
volume_percentage = [volume_percentage; zeros(length(data_C50_15),1)];
x = [x; data_C50_15(:,1)];
y = [y; data_C50_15(:,2)];

pressure = [pressure; 15*ones(length(data_6_02_15),1)];
fibre_length = [fibre_length; 6*ones(length(data_6_02_15),1)];
volume_percentage = [volume_percentage; 0.2*ones(length(data_6_02_15),1)];
x = [x; data_6_02_15(:,1)];
y = [y; data_6_02_15(:,2)];
pressure = [pressure; 15*ones(length(data_6_04_15),1)];
fibre_length = [fibre_length; 6*ones(length(data_6_04_15),1)];
volume_percentage = [volume_percentage; 0.4*ones(length(data_6_04_15),1)];
x = [x; data_6_04_15(:,1)];
y = [y; data_6_04_15(:,2)];
pressure = [pressure; 15*ones(length(data_6_06_15),1)];
fibre_length = [fibre_length; 6*ones(length(data_6_06_15),1)];
volume_percentage = [volume_percentage; 0.6*ones(length(data_6_06_15),1)];
x = [x; data_6_06_15(:,1)];
y = [y; data_6_06_15(:,2)];

pressure = [pressure; 15*ones(length(data_12_02_15),1)];
fibre_length = [fibre_length; 12*ones(length(data_12_02_15),1)];
volume_percentage = [volume_percentage; 0.2*ones(length(data_12_02_15),1)];
x = [x; data_12_02_15(:,1)];
y = [y; data_12_02_15(:,2)];
pressure = [pressure; 15*ones(length(data_12_04_15),1)];
fibre_length = [fibre_length; 12*ones(length(data_12_04_15),1)];
volume_percentage = [volume_percentage; 0.4*ones(length(data_12_04_15),1)];
x = [x; data_12_04_15(:,1)];
y = [y; data_12_04_15(:,2)];
pressure = [pressure; 15*ones(length(data_12_06_15),1)];
fibre_length = [fibre_length; 12*ones(length(data_12_06_15),1)];
volume_percentage = [volume_percentage; 0.6*ones(length(data_12_06_15),1)];
x = [x; data_12_06_15(:,1)];
y = [y; data_12_06_15(:,2)];

pressure = [pressure; 15*ones(length(data_18_02_15),1)];
fibre_length = [fibre_length; 18*ones(length(data_18_02_15),1)];
volume_percentage = [volume_percentage; 0.2*ones(length(data_18_02_15),1)];
x = [x; data_18_02_15(:,1)];
y = [y; data_18_02_15(:,2)];
pressure = [pressure; 15*ones(length(data_18_04_15),1)];
fibre_length = [fibre_length; 18*ones(length(data_18_04_15),1)];
volume_percentage = [volume_percentage; 0.4*ones(length(data_18_04_15),1)];
x = [x; data_18_04_15(:,1)];
y = [y; data_18_04_15(:,2)];
pressure = [pressure; 15*ones(length(data_18_06_15),1)];
fibre_length = [fibre_length; 18*ones(length(data_18_06_15),1)];
volume_percentage = [volume_percentage; 0.6*ones(length(data_18_06_15),1)];
x = [x; data_18_06_15(:,1)];
y = [y; data_18_06_15(:,2)];

% 准备BP神经网络的输入数据
input = [pressure, fibre_length, volume_percentage, x];
output = y;
% 打乱数据
flagTrain = length(output);
order = randperm(flagTrain);
nbertrain = round(0.7*flagTrain);% 提取训练和验证数据 70% 训练，30% 验证
XTrain = input(order(1:nbertrain),:);
YTrain = output(order(1:nbertrain));
XValidation = input(order(nbertrain+1:flagTrain),:);
YValidation = output(order(nbertrain+1:flagTrain));

3、仿真分析

4、参考论文

THE END