matlab里trim函数,matlab 中trim函数总出现Index exceeds matrix dimensions,求大神帮忙解决...
運行一個trim函數,可是總是錯誤
Index exceeds matrix dimensions.
Error in trim>trim_alg (line 164)
gg=[x(ix)-x0(ix);y(iy)-y0(iy);u(iu)-u0(iu)];
Error in trim (line 84)
[x,u,y,dx,options]=trim_alg(fcn,varargin{:});
不知道該怎么辦了。源程序如下:
P.gravity = 9.8;
%physical parameters of airframe
P.mass = 13.5 ;
P.Jx? ?= 0.8244;
P.Jy? ?= 1.135;
P.Jz? ?= 1.579;
P.Jxz??= 0.1204;
% aerodynamic coefficients
P.M? ?? ?? ?? ? = 50;
P.epsilon? ?? ? = 0.1592;
P.alpha0? ?? ???= 0.4712;
P.rho? ?? ?? ???= 1.2682;
P.c? ?? ?? ?? ? = 0.18994;
P.b? ?? ?? ?? ? = 2.8956;
P.S? ?? ?? ?? ? = 0.55;
P.S_prop? ?? ???= 0.2027;
P.k_motor? ?? ? = 80;
P.k_T_p? ?? ?? ?=0;
P.k_omega? ?? ? =0;
P.C_L_0? ?? ?? ?= 0.28;
P.C_L_alpha? ???= 3.45;
P.C_L_q? ?? ?? ?= 0.0;
P.C_L_delta_e? ?= -0.36;
P.C_D_0? ?? ?? ?= 0.03;
P.C_D_q? ?? ?? ?= 0.0;
P.C_D_alpha? ???=0.30;
P.C_D_delta_e? ?= 0.0;
P.C_M_0? ?? ?? ?= -0.02338;
P.C_M_alpha? ???= -0.38;
P.C_M_q? ?? ?? ?= -3.6;
P.C_M_delta_e? ?= -0.5;
P.C_Y_0? ?? ?? ?= 0.0;
P.C_Y_beta? ?? ?= -0.98;
P.C_Y_p? ?? ?? ?= -0.26;
P.C_Y_r? ?? ?? ?= 0.0;
P.C_Y_delta_a? ?= 0.0;
P.C_Y_delta_r? ?= -0.17;
P.C_ell_0? ?? ? = 0.0;
P.C_ell_beta? ? = -0.12;
P.C_ell_p? ?? ? = -0.26;
P.C_ell_r? ?? ? = 0.14;
P.C_ell_delta_a = 0.08;
P.C_ell_delta_r = 0.105;
P.C_n_0? ?? ?? ?= 0.0;
P.C_n_beta? ?? ?= 0.25;
P.C_n_p? ?? ?? ?= 0.022;
P.C_n_r? ?? ?? ?= -0.35;
P.C_n_delta_a? ?= 0.06;
P.C_n_delta_r? ?= -0.032;
P.C_prop? ?? ???= 1;
% wind parameters
P.wind_n = 0;%3;
P.wind_e = 0;%2;
P.wind_d = 0;
P.L_wx = 1250;
P.L_wy = 1750;
P.L_wz = 1750;
P.sigma_wx = 1;
P.sigma_wy = 1;
P.sigma_wz = 1;
% autopilot sample rate
P.Ts = 0.01;
% compute trim conditions using \'mavsim_chap5_trim.mdl\'
P.Va? ? = 13;? ?? ?? ?% desired airspeed (m/s)
gamma = 0*pi/180;??% desired flight path angle (radians)
R? ???= 0;? ?? ?? ?% desired radius (m) - use (+) for right handed orbit,
%? ?? ?? ?? ?? ?? ?? ?? ???(-) for left handed orbit
% first cut at initial conditions
P.pn0? ? =0;??% initial North position
P.pe0? ? = 0;??% initial East position
P.pd0? ? = 0;??% initial Down position (negative altitude)
P.u0? ???= P.Va; % initial velocity along body x-axis
P.v0? ???= 0;??% initial velocity along body y-axis
P.w0? ???= 0;??% initial velocity along body z-axis
P.phi0? ?= 0;??% initial roll angle
P.theta0 = 0;??% initial pitch angle
P.psi0? ?= 0;??% initial yaw angle
P.p0? ???= 0;??% initial body frame roll rate
P.q0? ???= 0;??% initial body frame pitch rate
P.r0? ???= 0;??% initial body frame yaw rate
X0=[0;0;0;P.Va;0;0;0;0;gamma;0;0;0];
U0=[0;0;0;1];
%initialize the trim para
X0? ???=[0;0;0;P.Va;0;0;0;gamma;0;0;0;0];
IX0? ? =[];
U0? ???=[0;0;0;1];
IU0? ? =[];
Y0? ???=[0;0;0;P.Va;0;0;0;0;0;0;0;0;];
IY0? ? =[4;5;6;8;9];
DX? ???=[0;0;P.Va*sin(gamma);0;0;0;0;0;0;0;0;0];
IDX? ? =[3;4;5;6;7;8;9;10;11;12];
% run trim commands
[x_trim, u_trim,y_trim,dx_trim]=trim(\'mavsim_trim\',X0,U0,Y0,IX0,IU0,IY0,DX,IDX);
P.u_trim = u_trim
P.x_trim = x_trim
% set initial conditions to trim conditions
% initial conditions
P.pn0? ? = x_trim(1);??% initial North position
P.pe0? ? = x_trim(2);??% initial East position
P.pd0? ? = x_trim(3);??% initial Down position (negative altitude)
P.u0? ???= x_trim(4);??% initial velocity along body x-axis
P.v0? ???= x_trim(5);??% initial velocity along body y-axis
P.w0? ???= x_trim(6);??% initial velocity along body z-axis
P.phi0? ?= x_trim(7);??% initial roll angle
P.theta0 = x_trim(8);??% initial pitch angle
P.psi0? ?= x_trim(9);??% initial yaw angle
P.p0? ???= x_trim(10);??% initial body frame roll rate
P.q0? ???= x_trim(11);??% initial body frame pitch rate
P.r0? ???= x_trim(12);??% initial body frame yaw rate
請大神幫忙解決一下,謝謝
總結
以上是生活随笔為你收集整理的matlab里trim函数,matlab 中trim函数总出现Index exceeds matrix dimensions,求大神帮忙解决...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 用户画像 | 标签数据存储之Elasti
- 下一篇: unity3D下载