format long
errors = zeros(1,12);
condnums = zeros(1,12);
h = zeros(1,12)
for k=0:11
    n=10*2^k;
    err = (initclampedmatrix(n)\sinusoidalforces(n)) - sinusoidalclampedcorrect(n);
    errors(1,k+1) = abs(err(n/2));
    condnums(1,k+1) = condest(initclampedmatrix(n), 2);
    h(1,k+1) = 2/n;
end
ax = plotyy(h, errors, h, condnums, 'loglog', 'loglog')
ylim(ax(1), [1e-12, 1e+2]);
title('Problem 7: Discretization Errors vs Condition Number, Clamped-Clamped w/Sinusoidal Pile');
xlabel('h ((meters between discretization points))');
ylabel(ax(1),'error at x=L (in meters)');
ylabel(ax(2),'condition number');

[errors]
[condnums]