Part III : Dealing with data

Module 2: Fitting

 
The following GNU Octave script fits the given specific heat data to a polynomial of the type $ aT + bT^3$.

% Load the specific heat data

S = load("CuSpHeatData.dat");

% Get the temperature and specific heat from the data file

T = S(:,1);
Cp = S(:,2);

% Plot the experimental data with open circles

plot(T,Cp,'o')
hold on

% Generate the design matrix

X = [T T.*T.*T];

% Calculate the coefficients a and b which are consistent with the given data

a = X\Cp

% Using the obtained a and b values, generate data points

t = (0:1.:25)';
Y = [t t.*t.*t]*a;

% Plot the fit

plot(t,Y,'.-')

% Label the axes

xlabel ("Temperature (in K)");
ylabel ("Specific heat (in J/mol/K)");

% Make the plot square and save the output file

axis('square')
print -depsc CuSpHeatFit.eps