Home > Src > Basis_functions > plot_legendre.m

plot_legendre

PURPOSE ^

PLOT_LEGENDRE plots 1D Legendre polynomials.

SYNOPSIS ^

function plot_legendre

DESCRIPTION ^

 PLOT_LEGENDRE  plots 1D Legendre polynomials.
             Formula  (2.3.2), pag. 75, CHQZ2,
             produces Fig. 2.12, pag. 83 CHQZ2

 plot_legendre % no input, no output

 Reference: CHQZ2 = C. Canuto, M.Y. Hussaini, A. Quarteroni, T.A. Zang,
                    "Spectral Methods. Fundamentals in Single Domains"
                    Springer Verlag, Berlin Heidelberg New York, 2006.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function plot_legendre
0002 % PLOT_LEGENDRE  plots 1D Legendre polynomials.
0003 %             Formula  (2.3.2), pag. 75, CHQZ2,
0004 %             produces Fig. 2.12, pag. 83 CHQZ2
0005 %
0006 % plot_legendre % no input, no output
0007 %
0008 % Reference: CHQZ2 = C. Canuto, M.Y. Hussaini, A. Quarteroni, T.A. Zang,
0009 %                    "Spectral Methods. Fundamentals in Single Domains"
0010 %                    Springer Verlag, Berlin Heidelberg New York, 2006.
0011 
0012 %   Written by Paola Gervasio
0013 %   $Date: 2007/04/01$
0014 
0015 addpath ../Level_0
0016 l0='1'; l1='x'; 
0017 l2=pol_legendre(1,l1,l0);
0018 l3=pol_legendre(2,l2,l1);
0019 l4=pol_legendre(3,l3,l2);
0020 nx1=51;
0021 x=linspace(-1,1,nx1)';
0022 y=zeros(nx1,5);
0023 y(:,1)=eval(l0); y(:,2)=eval(l1); y(:,3)=eval(l2); 
0024 y(:,4)=eval(l3); y(:,5)=eval(l4);
0025 
0026 for k=1:5
0027 fig=figure(...,
0028     'Name','1D Legendre polynomial',...
0029     'Visible','on');
0030 plot([-1.1,1.1],[0,0],'k');
0031 hold on
0032 plot([-1.,1.],[0,0],'k+');
0033 plot(x,y(:,k),'k','LineWidth',3)
0034 set(gca,'DataAspectRatioMode','manual',...
0035 'DataAspectRatio',[1,1,1],...
0036 'XTickLabelMode','manual','XTickLabel',[],'XTick',[],...
0037 'YTickLabelMode','manual','YTickLabel',[],'YTick',[],...
0038 'color','none','xcolor',[1 1 1],'ycolor',[1 1 1],...
0039 'Box','off','FontName','Times','Fontsize',16)
0040 if mod(k,2)==1
0041 set(gca,'Ylimmode','manual','Ylim',[-.55,1.1])
0042 else
0043 set(gca,'Ylimmode','manual','Ylim',[-1.1,1.1])
0044 end
0045 
0046 h1=text(-1.1,-0.2,0.,'-1','FontName','Times','Fontsize',16);
0047 h2=text(.99,-0.2,0.,'1','FontName','Times','Fontsize',16);
0048 h3=text(.6,.8,0.,['P',num2str(k-1)],'FontName','Times','Fontsize',16);
0049 nomefile=['figure2-legendre',num2str(k-1)];
0050 axis off
0051 
0052 end
0053 return

Generated on Fri 21-Sep-2007 10:07:00 by m2html © 2003