%% Sublimation of Dry Ice
%% Kurt Bryan and SIMIODE
% Script to start analysis of dry ice model in Section 3.5.1.
% The data, in time (seconds)/mass (grams) pairs:

times = [0., 120.0, 240.0, 360.0, 480.0, 600.0, 720.0, 840.0, 960.0, 1080.0, 1200.0, 1320.0, 1440.0, 1570.0, 1680.0, 1800.0, 1930.0, 2040.0, 2170.0, 2280.0, 2410.0, 2530.0, 2690.0, 2780.0, 2880.0, 3060.0, 3220.0, 3380.0, 3480.0, 3600.0];
masses = [25.525, 24.512, 23.524, 22.639, 21.765, 20.89, 20.043, 19.221, 18.431, 17.677, 16.936, 16.22, 15.548, 14.828, 14.213, 13.553, 12.91, 12.331, 11.689, 11.188, 10.566, 10.043, 9.377, 9.011, 8.616, 7.945, 7.404, 6.877, 6.593, 6.244];

% A plot of the data

plot(times,masses)

% A linear model (bad) of the form u(t) = b - m*t can be fit as follows

u = @(t,m,b) b - m*t
syms SS(m,b)
SS(m,b) = sum((u(times,m,b)-masses).^2);

% Then minimize SS with respect to m and b. But redo with your own (better/physically motivated) model for u(t)!