% plot soln and exact, assuming coarse mesh
% x is the nodal mesh, including endpoints
% Y is the calculated solution at the nodes
% use phi.m to interpolate values of solution
% intended to be run with supporting files from Lab 4

% mms 3/12/17

% N is number of nodes, including endpoints, must be odd >= 3
N=3;

[x,y]=solve7(N-2);

h=x(2)-x(1);

% compute nodes for refined mesh
% with midpoints, total of N+N-1 nodes
x=reshape(x,N,1); % make x a column vector

PLOTPTS=20*N;  % plot 10 pts between each node

xplot=linspace(x(1),x(N),PLOTPTS);
xplot=reshape(xplot,PLOTPTS,1); % make a column vector

yplot=zeros(PLOTPTS,1);
for kplt=1:PLOTPTS
  for k=1:N
    yplot(kplt)=yplot(kplt)+y(k)*phi(k-1,h,xplot(kplt));
  end
end

%plot(xplot,yplot,xplot,exact7(xplot))
plot(xplot,yplot,'b')
hold on
plot(xplot,exact7(xplot),'r')
plot(x,y,'ko')
hold off

print -dpng fullerror.png
axis([.3,.6,-.21,-.18])
print -dpng centererror.png

