⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 evalcg.m

📁 航天工程工具箱
💻 M
字号:
function [cg,m]=evalcg(comp)
%EVALCG  Evaluate center of gravity CG.
%   CG = EVALCG(COMP)  evaluates the center of gravity CG for
%   a rocket. The distance CG is counted from the tip of the nose.
%   The CG is only evaluated along its axial axis or the symmetry
%   line. COMP is a (Nx11) matrix where each row in COMP can be
%   any of the following rows in the table below:
%
%   TYPE SUBTYPE POSITION LENGTH ARG5 ARG6 ARG7 ARG8 ARG9 REL-CG MASS
%     1     1     delta    len    0    d    -    -    -    rpos   w
%     1     2     delta    len    0    d    -    -    -    rpos   w
%     1     3     delta    len    0    d    -    -    -    rpos   w
%     2     -      pos     len    0    d    -    -    -    rpos   w
%     3     1      pos     len   d1   d2    -    -    -    rpos   w
%     3     2      pos     len   d1   d2    -    -    -    rpos   w
%     4     -      pos      a     b    R    S    m    n    rpos   w
%     5     -      pos     len    -    d    -    -    n    rpos   w
%
%   This function however, only deals with elements from column
%   TYPE, POSITION, ARG9, REL-CG and MASS. Dashes represents NaNs.
%   For the case with TYPE=4,5 the column MASS represents the mass
%   of one of the fins/parts.
%   The meaning of TYPE and SUBTYPE is given in the following table:
%
%      TYPE SUBTYPE      COMPONENT
%        1     1      :   Nose, conical
%        1     2      :   Nose, ogive
%        1     3      :   Nose, parabolic
%        2     -      :   Body tube
%        3     1      :   Conical shoulder
%        3     2      :   Conical boattail
%        4     -      :   Fins
%        5     -      :   Other (internal)
%
%   The meaning of the abbreviations in the first table above is the
%   following:
%
%      delta : For approximations of the nose cone
%              this is the distance from the real tip and the
%              approximated tip
%      pos   : Position of component counted from real tip of nose
%      rpos  : Position of relative CG counted from the top of the
%              component. For the nose it is from the real tip (x=0)
%      len   : Length of component (or length of approx nose cone)
%      d     : Diameter at the nose base or diameter of tube or
%              "other"
%      d1    : Upper diameter
%      d2    : Lower diameter
%      n     : Number of fins (3,4 or 6), or number of parts
%      w     : Weight/mass of component
%
%   You can also type:
%   [CG,M] = EVALCG(COMP)  where the second output argument M is the 
%   rocket's total mass.
%
%   See also EVALCP, RCKPLOT, EVALDCM, SMARG.

% Copyright (c) 2003-07-19, B. Rasmus Anthin.
% Revision 2003-07-23.

if sum(comp(:,1)==1)~=1
   error('Must have exactly one nose cone.')
end

for i=1:size(comp,1)
   pos(i)=comp(i,3);
   rcg(i)=comp(i,10);
   n=1;
   if comp(i,1)==1
      x(i)=rcg(i);
   else
      x(i)=pos(i)+rcg(i);
   end
   if any(comp(i,1)==(4:5))
      n=comp(i,9);
   end
   m(i)=n*comp(i,11);
end

cg=evaldcm(x,m);
m=sum(m);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -