/ concept-collection / windowedFourierProjection
Sign in
concept-collection / windowedFourierProjection
windowedFourierProjection / wfp_1Dspringscattering / plotSolnAndError.m
35 lines · 1.0 KBCodeBlameHistory
8748c66added codenalhassanieh 1function plotSolnAndError(t,x,un,ue,figFile,prechar,order,tFinal,savePlot)
2% PLOTSOLNANDERROR plots the solution and error
3%
4% plotSolnAndError(t,tn,sn,src,sige,figFile,prechar,order,tFinal,plotOption)
5% Inputs:
6% tn: uniform time grid
7% sn: density grid function
8% sige: exact density function
9% figFile: file to store figures
10% prechar: character to precede name of figure
12figure(1);
13plot(x,un,'-o','LineWidth',2); hold on
14plot(x,ue,'-x','LineWidth',2);hold off
15title(sprintf('Computed vs exact at t = %1.1f',t));
16axis tight;
17legend('u','u_e','Location','best');
18xlabel('x'); ylabel('y');
19set(gca,'fontSize',16);
20if(savePlot == 1)
21 saveas(gcf,sprintf('%s/%sDScomputed%d_%d',figFile,prechar,order,round(tFinal)),'png');
22end
24figure(2);
25plot(x,un-ue,'LineWidth',2);
26title(sprintf('Error t = %1.1f',t));
27axis tight;
28legend('error','Location','best');
29xlabel('t'); ylabel('y');
30set(gca,'fontSize',16);
31if(savePlot == 1)
32 saveas(gcf,sprintf('%s/%sDSerror%d_%d',figFile,prechar,order,round(tFinal)),'png');
33end
35end
moveopenescclose