x=[0.1;0.07;0.05;0.03;0];
r=[-98.9407;-105.7183;-111.2423;-116.0320;-120.0462];
plot(x, r, 'r*-', 'LineWidth', 2);
% Fit to a cubic
coefficients = polyfit(x, r, 4)
xFit = linspace(min(x), max(x), 100);
rFit = polyval(coefficients, xFit);
hold on;
plot(xFit, rFit, 'b-', 'LineWidth', 2);
grid on;
legend('Actual', 'fit');
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Get rid of tool bar and pulldown menus that are along top of figure.
set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
% Equation is a1*x^4 + a2*x^3 + a3*x^2 + a4*x + a5
% First derivative is 4*a1*x^3 + 3*a2*x^2 + 2*a3*x + a4
% Second derivative is 12*a1*x^2 + 6*a2*x + 2*a3
a1 = coefficients(1)
a2 = coefficients(2)
a3 = coefficients(3)
deriv2 = 12*a1*xFit.^2 + 6*a2*xFit + 2*a3