0001 function plot_lagrange
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 addpath ../Level_0
0018 nx=4;
0019 xga=-1; xgb=1.;
0020 npdx=nx+1;
0021 [xgl,wx]=xwlgl(npdx);
0022 nx1=51;
0023 y=zeros(nx1,5);
0024 x=linspace(-1,1,nx1)';
0025 a=intlag_lgl(xgl, x);
0026
0027 for i=1:npdx
0028 ygl=zeros(npdx,1); ygl(i)=1;
0029 y(:,i)=a*ygl;
0030
0031 fig=figure(...
0032 'Name','1D Lagrange polynomial',...
0033 'Visible','on');
0034 plot([-1.2,1.2],[0,0],'k'); hold on
0035 plot(xgl,zeros(npdx,1),'k+');
0036 plot(x,y(:,i),'k','LineWidth',3)
0037 set(gca,'DataAspectRatioMode','manual',...
0038 'DataAspectRatio',[1,1,1],...
0039 'XTickLabelMode','manual','XTickLabel',[],'XTick',[],...
0040 'YTickLabelMode','manual','YTickLabel',[],'YTick',[],...
0041 'color','none','xcolor',[1 1 1],'ycolor',[1 1 1],...
0042 'Box','off','FontName','Times','Fontsize',16)
0043 if mod(i,2)==1
0044 set(gca,'Ylimmode','manual','Ylim',[-.55,1.1])
0045 else
0046 set(gca,'Ylimmode','manual','Ylim',[-1.1,1.1])
0047 end
0048 h1=text(-1.2,-0.2,0.,'-1','FontName','Times','Fontsize',16);
0049 h2=text(.99,-0.2,0.,'1','FontName','Times','Fontsize',16);
0050 h3=text(.57,.8,0.,['L',num2str(i-1)],'FontName','Times','Fontsize',16);
0051 axis off
0052 nomefile=['figure2-lagrange',num2str(i-1)];
0053
0054
0055 end
0056 return