《飞行器系统仿真与 CAD学习报告
第一部分仿真(40)
r(0) = 5km, q(0) = 60deg, (0) = 30deg,V = , V m= ,刘士豪 1Ma = 340m/s, k = 2
(3) 用窗口菜单对(1), (2)进行仿真,动态显示结果; (4)用命令行对(1), (2)进行仿真,以图形显示结果
答:
(2)用MATLA语言编写S函数
function [sys,x0,str,ts]=CAD1_sfun(t,x,u,flag) switch flag
case 0
[sys,x0,str,ts]=mdlInitializeSizes;
case 1
sys = mdlDerivatives(t,x,u);
case 3
sys = mdlOutputs(t,x,u);
case {2,4,9}
sys = [];
otherwise
error( 'unhandled flag=' ,num2str(flag))
end
function [sys,x0,str,ts]=mdlInitializeSizes sizes=simsizes;
=3;
=0;
=3;
=0;
=1;
=1;
sys=simsizes(sizes);
str=[];
x0=[5000,pi/3,pi/6];
ts=[0 0];
function sys=mdlDerivatives(t,x,u)
vm=*340;
v=*340;
k=2;
dx(1)=vm*cos(x(2))-v*cos(x(2)-x(3));
dx(2)=(v*sin(x(2)-x(3))-vm*sin(x(2)))/x(1);
dx(3)=k*dx(2);
sys=dx;
function sys=mdlOutputs(t,x,u)海风移动
sys=x;中国质量万里行
调用 S 函数的模型框图
(3) 框图仿真结果:
S函数仿真结果:
(4)命令输入
clear;clc
[t x ] = sim( 'CAD1' );
hSimulink = figure();
subplot(3, 1, 1);
公民道德建设实施纲要plot(t,x(:,1)); grid; ylabel( 'r' );
subplot(3, 1, 2);
plot(t,x(:,2)); grid; ylabel( subplot(3, 1, 3); plot(t,x(:,3)); grid; ylabel( | 'q' ); 'sigma' |
[t x ] = sim( 'CAD1_S'); | |
市场需求预测hSFun = figure(); | |
subplot(3, 1, 1); | |
plot(t,x(:,1)); grid; ylabel( | 'r' ); |
subplot(3, 1, 2); | |
plot(t,x(:,2)); grid; ylabel( | 'q' ); |
subplot(3, 1, 3); | |
plot(t,x(:,3)); grid; ylabel( | 'sigma' |
模型仿真结果: | |
S 函数仿真结果: | |
题目 2:给出动态方程 x (1莫麟传奇之四大古国全集 | x2)x |
| |
);
);
tx 1; x(0) 1, x(0) 0
⑴ 用MATLA语言编写S—函数;