errors = zeros(1,12);
condnums = zeros(1,12);
for k=0:11
    n=10*2^k;
    err = (initmatrix(n)\simpleforces(n)) - simplecorrect(n);
    errors(1,k+1) = abs(err(n));
    condnums(1,k+1) = condest(initmatrix(n), 2);
    disp('Cond number at ');
    disp(n);
    disp(condnums(1,k+1));
end
ax = plotyy(10*2.^(0:11), errors, 10*2.^(0:11), condnums, 'loglog', 'loglog')
ylim(ax(1), [1e-16, 1e-2]);
title('Problem 3: Discretization Errors vs Condition Number, Simple Case');
xlabel('n (# of grid steps)');
ylabel(ax(1),'error at x=L (in meters)');
ylabel(ax(2),'condition number');

[errors]
[condnums]