✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。

🍎个人主页:Matlab科研工作室

🍊个人信条:格物致知。

⛄ 内容介绍

基于人工神经网络(Artificial Neural Network, ANN)进行非线性系统识别是一种常见的方法。ANN通过模拟人脑神经元之间的连接和信息传递过程,能够学习和建模非线性系统的输入输出关系。下面将介绍基于ANN进行非线性系统识别的基本原理和步骤。

  1. 数据准备:收集非线性系统的输入和输出数据,并进行预处理,如归一化或标准化处理,以提高网络训练的效果和准确性。
  2. 网络结构设计:选择合适的ANN结构,包括输入层、隐藏层和输出层的节点数、层数以及激活函数的选择。网络结构的设计应根据具体问题和数据特点进行调整。
  3. 数据划分:将数据集划分为训练集、验证集和测试集。训练集用于网络参数的训练,验证集用于调整网络结构和防止过拟合,测试集用于评估网络的性能。
  4. 网络训练:使用训练集数据对ANN进行训练,通过反向传播算法或其他优化算法来更新网络参数,使得网络的输出逼近实际输出。
  5. 网络验证和调整:使用验证集数据评估网络的性能,并根据验证结果进行网络结构的调整,如调整隐藏层节点数、增加正则化项等,以提高网络的泛化能力。
  6. 网络测试:使用测试集数据对训练好的ANN进行性能评估,验证其在未知数据上的准确性和鲁棒性。
  7. 结果分析:分析网络输出与实际输出之间的差异,评估网络的识别精度和预测能力,并根据需要进行进一步优化或改进。

需要注意的是,ANN的训练过程是一个迭代优化的过程,可能需要多次调整网络参数和结构,并进行多轮训练才能得到较好的结果。此外,对于复杂的非线性系统,可能需要更深层次、更复杂的ANN结构来提高识别性能。

⛄ 部分代码

clear; clc; close all;

%Input
%--------------------------------------------------------------------------

%Nodes Coordinates and Degrees of Freedoms
%------------------------------------------
Node{1}.x=0; Node{1}.y=0;                                 %Node Coordinates
Node{2}.x=5; Node{2}.y=0;
Node{3}.x=5; Node{3}.y=5;
Node{4}.x=0; Node{4}.y=5;

Node{1}.DOFx=1;  Node{1}.DOFy=2;  Node{1}.DOFtheta=3;     %Indices for x, y, and Rotation Degree of Freedoms.  
Node{2}.DOFx=4;  Node{2}.DOFy=5;  Node{2}.DOFtheta=6;
Node{3}.DOFx=7;  Node{3}.DOFy=8;  Node{3}.DOFtheta=9;
Node{4}.DOFx=10; Node{4}.DOFy=11; Node{4}.DOFtheta=12;

%Material
%-----------------
Material{1}.E=200e9;                                      %Modulus of Elasticity
Material{1}.f_y=400e6;                                    %Stress Beyond Which the Stiffness Decreases
Material{1}.Ep=2e9;                                       %Reduced Modulus of Elasticity
Material{1}.rho=7800;                                     %Material Density

%Elements Nodes Connectivity, Area, Moment of Inertia, Modulus of Elasticity, Density, and Rayleigh Damping Parameters
%---------------------------------------------------------------------------------------------------------------------
Element{1}.Nodes=[1 4];                                   %Element Nodes Connectivity
Element{1}.Material=1;                                    %Element Material
Element{1}.alpha=0.001;                                   %Element Rayleigh Damping Parameter alpha
Element{1}.beta=0.001;                                    %Element Rayleigh Damping Parameter beta

b1=0.1; h1=0.1;
for i=1:1:10
Element{1}.Section{i}.x=1/sqrt(3)*b1/2*[-1 -1 1 1];       %Element Section integation points x coordinates
Element{1}.Section{i}.y=1/sqrt(3)*h1/2*[-1 1 -1 1];       %Element Section integation points y coordinates
Element{1}.Section{i}.A=b1*h1/4*[1 1 1 1];                %Element Section integation points areas
Element{1}.Section{i}.e=[0 0 0 0];                        %Element Section integation points initial stresses
Element{1}.Section{i}.s=[0 0 0 0];                        %Element Section integation points initial strains
Element{1}.Section{i}.k=[0 0 0 0];                        %Element Section integation points initial hardening
end

Element{2}.Nodes=[3 2];
Element{2}.Material=1; 
Element{2}.alpha=0;
Element{2}.beta=0.00001;

b2=0.1; h2=0.1;
for i=1:1:10
Element{2}.Section{i}.x=1/sqrt(3)*b2/2*[-1 -1 1 1];     
Element{2}.Section{i}.y=1/sqrt(3)*h2/2*[-1 1 -1 1];    
Element{2}.Section{i}.A=b2*h2/4*[1 1 1 1]; 
Element{2}.Section{i}.e=[0 0 0 0];
Element{2}.Section{i}.s=[0 0 0 0]; 
Element{2}.Section{i}.k=[0 0 0 0]; 
end

Element{3}.Nodes=[4 3];
Element{3}.Material=1; 
Element{3}.alpha=0;
Element{3}.beta=0.00001;

b3=0.1; h3=0.1;
for i=1:1:10
Element{3}.Section{i}.x=1/sqrt(3)*b3/2*[-1 -1 1 1];     
Element{3}.Section{i}.y=1/sqrt(3)*h3/2*[-1 1 -1 1];    
Element{3}.Section{i}.A=b3*h3/4*[1 1 1 1]; 
Element{3}.Section{i}.e=[0 0 0 0];
Element{3}.Section{i}.s=[0 0 0 0]; 
Element{3}.Section{i}.k=[0 0 0 0]; 
end

%Support, Support Displacement, and Applied Force
%-------------------------------------------------
steps=1000;                                               %Number of Analysis Steps
Support=[1 2 3 4 5 6];                                    %Indices of Degrees of Freedom of Supports 
NSupport=length(Support);
U_s=zeros(NSupport,steps);                                %Support Displacement Matrix of Size (Number of Supports, Number of Analysis Steps)                           
dU_s=zeros(NSupport,steps);                               %Support Velocity Matrix of Size (Number of Supports, Number of Analysis Steps)    
ddU_s=zeros(NSupport,steps);                              %Support Acceleration Matrix of Size (Number of Supports, Number of Analysis Steps)    
NNode=length(Node); 
Force=zeros(3*NNode,steps);                               %Force Matrix of Size (Number of Degrees of Freedoms=3*Number of Nodes, Number of Analysis Steps)
Force(10,:)=600.*[1:steps].*sin(1*[1:steps]/10);
fs=300;                                                   %Sampling Frequency
delta=10e-4;                                              %Convergance criterion for residual force

%Processing
%--------------------------------------------------------------------------
[Node,Element,F_s,Elements_N]=Analysis(Node,Element,Material,Support,U_s,dU_s,ddU_s,Force,fs,delta);

shear=zeros(steps,1);
for i=1:1:steps
shear(i)=Elements_N{i}{1}.f(1);
end

%Output
%--------------------------------------------------------------------------
Mag_Factor=1;                                             %Magnification Factor for Plot
step=steps;                                               %Step Number to be Plotted
Plot_Results(Node,Element,Mag_Factor,0,step); title(strcat('Deflected Shape @ Step=',num2str(step)));
Plot_Results(Node,Element,Mag_Factor,1,step); title(strcat('Axial Strain @ Step=',num2str(step)));
Plot_Results(Node,Element,Mag_Factor,2,step); title(strcat('Curvature @ Step=',num2str(step)));
Plot_Results(Node,Element,Mag_Factor,3,step); title(strcat('Axial Force @ Step=',num2str(step))); 
Plot_Results(Node,Element,Mag_Factor,4,step); title(strcat('Moment @ Step=',num2str(step))); 

t=[0:1:steps-1]/fs;
figure;
subplot(4,1,1);
plot(t,Force(10,:));
xlabel('Time (s)');
ylabel('Force (N)');
title('Horizontal Force, DISP, VEL, and ACC at Node 4');
subplot(4,1,2);
plot(t,Node{4}.Ux);
xlabel('Time (s)');
ylabel('DISP (m)');
subplot(4,1,3);
plot(t,Node{4}.dUx);
xlabel('Time (s)');
ylabel('VEL (m/s)');
subplot(4,1,4);
plot(t,Node{4}.ddUx);
xlabel('Time (s)');
ylabel('ACC (m/s^2)');

%Identification using neural network
%--------------------------------------------------------------------------

X=Force(10,:);                         %Input of neural network is forces
T=[Node{4}.Ux*100000 ; shear'];        %Output of neural network is displacement and base shear

[X,~] = tonndata(X,1,0);               %Change format of input data
[T,~] = tonndata(T,1,0);               %Change format of output data

net = narxnet(0,4,4);                  %Create (nonlinear autoregressive with external input) network with 0 input delays and 4 output delays

[Xs,Xi,Ai,Ts] = preparets(net,X,{},T); %Prepares data for training
net = train(net,Xs,Ts,Xi,Ai);          %Train the network
view(net)                              %View the network
Yopen = net(Xs,Xi,Ai);                 %Predict Output

net = closeloop(net);                  %convert to closed loop neural network
view(net);                             %view closed-loop network
[Xs,Xi,Ai,Ts] = preparets(net,X,{},T); %Prepares data for training
net = train(net,Xs,Ts,Xi,Ai);          %Train the network
Yclosed = net(Xs,Xi,Ai);               %Predict Output


%Plot output with predicted output
%--------------------------------------------------------------------------
T=cell2mat(T);
Yopen=cell2mat(Yopen);
Yclosed=cell2mat(Yclosed);

figure;
plot(t(5:end),T(1,5:end)/100000,'b-',t(5:end),Yopen(1,:)/100000,'r--',t(5:end),Yclosed(1,:)/100000,'k-.'); xlabel('Time (sec)');  ylabel('DISP (m)');
legend('Actual','Predicted (openloop)','Predicted (closedloop)');
figure;
plot(T(1,5:end)/100000,T(2,5:end),'b-',Yopen(1,:)/100000,Yopen(2,:),'r--',Yclosed(1,:)/100000,Yclosed(2,:),'k-.'); 
xlabel('Interstory Drift (m)');
ylabel('Interstory Shear (N)');
legend('Actual','Predicted (openloop)','Predicted (closedloop)');

⛄ 运行结果

基于 ANN 进行非线性系统识别附matlab代码_无人机

基于 ANN 进行非线性系统识别附matlab代码_无人机_02

基于 ANN 进行非线性系统识别附matlab代码_路径规划_03

⛄ 参考文献

[1] 曲东才.基于ANN逆模型的非线性系统辨识和控制仿真[C]//中国控制与决策学术年会.2006.DOI:ConferenceArticle/5aa2fa4cc095d72220ac9bd4.

⛳️ 代码获取关注我

❤️部分理论引用网络文献,若有侵权联系博主删除
❤️ 关注我领取海量matlab电子书和数学建模资料

🍅 仿真咨询

1.卷积神经网络(CNN)、LSTM、支持向量机(SVM)、最小二乘支持向量机(LSSVM)、极限学习机(ELM)、核极限学习机(KELM)、BP、RBF、宽度学习、DBN、RF、RBF、DELM实现风电预测、光伏预测、电池寿命预测、辐射源识别、交通流预测、负荷预测、股价预测、PM2.5浓度预测、电池健康状态预测、水体光学参数反演、NLOS信号识别、地铁停车精准预测、变压器故障诊断
2.图像识别、图像分割、图像检测、图像隐藏、图像配准、图像拼接、图像融合、图像增强、图像压缩感知
3.旅行商问题(TSP)、车辆路径问题(VRP、MVRP、CVRP、VRPTW等)、无人机三维路径规划、无人机协同、无人机编队、机器人路径规划、栅格地图路径规划、多式联运运输问题、车辆协同无人机路径规划
4.无人机路径规划、无人机控制、无人机编队、无人机协同、无人机任务分配
5.传感器部署优化、通信协议优化、路由优化、目标定位
6.信号识别、信号加密、信号去噪、信号增强、雷达信号处理、信号水印嵌入提取、肌电信号、脑电信号
7.生产调度、经济调度、装配线调度、充电优化、车间调度、发车优化、水库调度、三维装箱、物流选址、货位优化
8.微电网优化、无功优化、配电网重构、储能配置
9.元胞自动机交通流 人群疏散 病毒扩散 晶体生长