Code covered by the BSD License

# Using Analytical Tools to Gain Insight and Speed-up Num. Analysis in MATLAB & Symbolic Math Toolbox

### Deepak Ramaswamy (view profile)

28 Jan 2013 (Updated )

files from the webinar

Mass(time, rocketStartTime, engineOffTime)
```function m = Mass(time, rocketStartTime, engineOffTime)

originalMass = 6500; %[kg]
dM_dt = @(t)dMassDt(t, rocketStartTime, engineOffTime);

if time < rocketStartTime
m = originalMass + integral(dM_dt,0,time);
elseif time < engineOffTime
m = originalMass + integral(dM_dt,0,rocketStartTime) ...
+ integral(dM_dt,rocketStartTime,time);
else
m = originalMass + integral(dM_dt,0,rocketStartTime) ...
+ integral(dM_dt,rocketStartTime, engineOffTime);
end

%%%%%%%%%%%
% persistent rs eo mass t
% if isempty(rs)
%     rs = rocketStartTime;
%     eo = engineOffTime;
% end
%
% if isempty(mass) || rs ~= rocketStartTime || eo ~= engineOffTime
%     dM_dt = @(t,y)dMassDt(t, rocketStartTime, engineOffTime);
%     originalMass = 6500; %[kg]
%     [t1,mass1] = ode45(dM_dt, [0,rocketStartTime], 0);
%     [t2,mass2] = ode45(dM_dt, [rocketStartTime, engineOffTime], mass1(end));
%     mass = originalMass+[mass1(1:end-1);mass2(1:end)];
%     t = [t1(1:end-1); t2(1:end)];
%     rs = rocketStartTime;
%     eo = engineOffTime;
% end
%
% if time > engineOffTime
%     m = mass(end);
% else
%     m = spline(t,mass,time);
% end

```