meansquarederrorline;               % generate data

c0 = 2.0;
eps = 0.00001;
thresh = 1.0;
[cest, cs, mses] = gradientDescentCubic(x, y, c0, eps, thresh);

subplot(2, 2, 1);                   % top left panel
hold on;
plot(cs, '-o');
plot([1, length(cs)], [c, c], 'k'); % line indicating true c value
hold off;
xlabel('Iteration');
ylabel('C');
subplot(2, 2, 3);                   % bottom left panel
plot(mses, '-o');
xlabel('Iteration steps');
ylabel('MSE');
subplot(1, 2, 2);                   % right panel
hold on;
% generate x-values for plottig the fit:
xx = min(x):0.01:max(x);
yy = cest * xx.^3;
plot(xx, yy);
plot(x, y, 'o');                    % plot original data
xlabel('Size [m]');
ylabel('Weight [kg]');
legend('fit', 'data', 'location', 'northwest');