资源简介
基于神经网络的水下机器人控制,里面有水下机器人的建模模型
代码片段和文件信息
function aaaaaaa=under_robot()
clc;
clear all
%global S_0
global W
W=rand(56)/10;
yW=rand(405)/10;yc=rand(4034)/10;yB=rand(4034)/10+1; %40 rule numbers and 34 input variable
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%系统调节参数%%%%%%%%%%%%%%%%%%%%%%%%%
%---------------------------------系统初始值--------------------------%
Tmax=10;t=0; h=0.01; %仿真时间
%会出现奇异问题。该怎么解决。%该控制器可能存在奇异问题。如何解决呢?能否和非奇异terminal 结合起来呢。
x10=[0.5;0.5;4;4;4;4;zeros(61)]; %初角度和初始角速度
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%程序仿需要参数%%%%%%%%%%%%%%%%%%%%
n=1; u=0;
%--------------------------------主程序-------------------------------%
while t<=Tmax
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%四阶龙格计算%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[udXdyWdycdyB]=derives(tx10yWycyBu);
m1=h*dX; t=t+0.5*h;X=x10+0.5*m1;
n1=h*dyW; YW=yW+0.5*n1;
o1=h*dyc; Yc=yc+0.5*o1;
p1=h*dyB; YB=yB+0.5*p1;
[udXdyWdycdyB]=derives(tXYWYcYBu);
m2=h*dX; X=x10+0.5*m2;
n2=h*dyW; YW=yW+0.5*n2;
o2=h*dyc; Yc=yc+0.5*o2;
p2=h*dyB; YB=yB+0.5*p2;
[udXdyWdycdyB]=derives(tXYWYcYBu);
m3=h*dX; t=t+0.5*h; X=x10+m3;
n3=h*dyW; YW=yW+0.5*n3;
o3=h*dyc; Yc=yc+0.5*o3;
p3=h*dyB; YB=yB+0.5*p3;
[udXdyWdycdyB]=derives(tXYWYcYBu);
m4=h*dX; n4=h*dyW; o4=h*dyc; p4=h*dyB;
x10=x10+(1/6)*(m1+2*m2+2*m3+m4);
yW=yW+(1/6)*(n1+2*n2+2*n3+n4);
yc=yc+(1/6)*(o1+2*o2+2*o3+o4);
yB=yB+(1/6)*(p1+2*p2+2*p3+p4);
%%%%%%%%%%%%%%%%%%%%%%保存结果%%%%%%%%%%%%%%%%%%%%%
YY(:n)=x10(1:end:);time(n)=t; UU(:n)=u; n=n+1;
end
%%%%%%%%%%%%%%%%%%%%%%%ploting%%%%%%%%%%%%%%%%%%%%%
t=time;
R1=2*sin(t);R2=2*sin(2*t);R3=2*sin(4*t);R4=10*sin(0.25*t);R5=10*sin(0.5*t);R6=2*sin(2*t);
figure(1) ; plot(timeR1‘b‘timeYY(1:)‘r‘);grid on ;legend(‘x positon‘)
figure(2); plot(timeR2‘b‘timeYY(2:)‘r‘);grid on ; legend(‘y positon‘)
figure(3); plot(timeR3‘b‘timeYY(3:)‘r‘);grid on ;legend(‘z positon‘)
figure(4) ; plot(timeR4‘b‘timeYY(4:)‘r‘);grid on ;legend(‘pitch angle speed‘)
figure(5); plot(timeR5‘b‘timeYY(5:)‘r‘);grid on ;legend(‘roll angle speed‘)
figure(6); plot(timeR6‘b‘timeYY(6:)‘r‘);grid on ;legend(‘yaw angle speed‘)
figure(7); plot(timeUU(1:));grid on
figure(8); plot(timeUU(2:)‘b‘);grid on
figure(9); plot(timeUU(3:)‘b‘);grid on
figure(10); plot(timeUU(4:));grid on
figure(11); plot(timeUU(5:)‘b‘);grid on
figure(12); plot(timeUU(6:)‘b‘);grid on
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%--子函数----%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [udXdyWdycdyB]=derives(tXXYWYcYBu)
expa
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 13188 2013-01-23 09:16 under_robot.m
----------- --------- ---------- ----- ----
13188 1
- 上一篇:简单的Matlab人脸识别
- 下一篇:BP GA预测时间序列
评论
共有 条评论