function matrix1% solve matrix equation (check on timing and errors)% same as matrix.m but plots errorn=2;for in=1:12    n=2*n;        % enter matrix A    A=zeros(n,n);    for i=1:n        A(i,i)=2;        if i>1            A(i,i-1)=-1;        end        if i<n            A(i,i+1)=-1;        end    end    %A(n,2)=5;        % pick exact solution    xe=ones(n,1);    %xe=rand(n,1);    b=A*xe;        % solve equation    tic;    xc=A\b;    tt=toc;        % compute error    dim(in)=n;    error(in)=norm(xe-xc,inf);    fprintf('\n n = %d   Error = %5.1e  Time = %5.1e',n,error(in),tt)endfprintf('\n\n')% plot error curveclf% get(gcf)set(gcf,'Position', [1 925 560 420])loglog(dim,error,'--or','LineWidth',1.5,'MarkerSize',8)xlabel('Size of Matrix (n)')ylabel('Error')grid onbox onset(gca,'FontSize',16,'FontWeight','bold')% determine linear fit to curvefor i=1:12    x(i)=log10(dim(i));    y(i)=log10(error(i));endpolyfit(x,y,1)