📄 loadeng.m
字号:
function motor=loadeng(fname)
%LOADENG Load rocket motor data from wRASP file.
% MOTOR = LOADENG([FNAME]) loads rocket motor data from
% file FNAME, or if omitted invokes a file selection window
% where you can select a rocket motor.
% MOTOR will be a structure:
%
% MOTOR.NAME : the motor code
% MOTOR.MANUF : the manufacturer
% MOTOR.D : the diameter [mm]
% MOTOR.L : the length [mm]
% MOTOR.DELAY : delay charge(s) [s]
% MOTOR.MF : mass of fuel [kg]
% MOTOR.MM : mass of empty motor [kg]
% MOTOR.THRUST : the thrust curve (Nx2) matrix
% 1st col. in [s], 2:nd col. in [N]
%
% New wRASP files should be placed in the .../motor/eng/
% directory.
%
% See also SAVEENG, PLOTENG, RCKSIM.
% Copyright (c) 2003-01-12, B. Rasmus Anthin.
% Revision: 2003-01-16, 2003-04-03, 2003-06-14,
% 2003-06-19 - 2003-06-20.
godir(mfilename)
cd(fullfile('motor','eng'))
if nargin
path=pwd;
if ~any(fname=='.')
fname=[fname '.eng'];
end
else
[fname,path]=uigetfile('*.eng','Load Motor Data');
end
godir
if ~ischar(fname)
motor=[];
return
end
fp=fopen(fullfile(path,fname),'r');
while 1
line=fgetl(fp);
if line(1)~=';', break;end
end
[name,R]=strtok(line);
[D,R]=strtok(R); D=str2num(D);
[L,R]=strtok(R); L=str2num(L);
[Rd,R]=strtok(R);
i=0;
while ~isempty(Rd)
[Td,Rd]=strtok(Rd,'-');
i=i+1;
if upper(Td)=='P' %dunno what this means anaways.
delay(i)=0;
elseif strcmp(upper(Td),'NONE')
delay(i)=0;
else
delay(i)=str2num(Td);
end
end
[mf,R]=strtok(R); mf=str2num(mf);
[m0,R]=strtok(R); m0=str2num(m0); %start/full/total mass
[manuf,R]=strtok(R);
i=0;
while 1
line=fgetl(fp);
if line(1)==';' | ~ischar(line), break;end
i=i+1;
T(i,:)=str2num(line);
end
motor.name=name;
motor.manuf=manuf;
motor.D=D;
motor.L=L;
motor.delay=delay;
motor.mf=mf;
motor.mm=m0-mf;
motor.thrust=T;
fclose(fp);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -