Add new headers.
[scilab.git] / scilab / modules / graphics / macros / fplot2d.sci
1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) INRIA
3 // This file must be used under the terms of the CeCILL.
4 // This source file is licensed as described in the file COPYING, which
5 // you should have received as part of this distribution.  The terms
6 // are also available at    
7 // http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
8
9 function []=fplot2d(xr,f,style,strf,leg,rect,nax,void)
10         // 2D plot of function f : a Scilab function or the name (as a string)
11         //  of a dynamically linked function.
12         // Enter fplot2d() for an example.
13         // deff('<y>=f(x)','y=sin(x)+cos(x)');
14         // fplot2d(f,0:0.1:%pi);
15         //!
16         
17         [lhs,rhs]=argn(0)
18         if rhs <= 0 then   // demo
19                 
20                 title_demo = [
21                         '';
22                         'Demo of fplot2d()';
23                         '========================================';
24                         ''];
25                 
26                 s_mat=[
27                         'deff(''[y]=f(x)'',''y=sin(x)+cos(x)'');';
28                         'fplot2d(0:0.1:%pi,f);'];
29                 
30                 write(%io(2),title_demo);
31                 write(%io(2),s_mat);
32                 write(%io(2),' ');
33                 execstr(s_mat);
34                 return
35         end
36         
37         if type(xr)=='10' then // logflag passed first
38                 error('First argument must be the discretization of x')
39         elseif rhs < 2 then 
40                 error('at least 2 input arguments required')
41         end
42         //handling optionnal arguments
43         
44         opts=[]
45         
46         if exists('style','local')==1 then opts=[opts,'style=style'],end
47         if exists('strf','local')==1 then opts=[opts,'strf=strf'],end
48         if exists('leg','local')==1 then opts=[opts,'leg=leg'],end
49         if exists('rect','local')==1 then opts=[opts,'rect=rect'],end
50         if exists('nax','local')==1 then opts=[opts,'nax=nax'],end
51         if exists('logflag','local')==1 then opts=[opts,'logflag=logflag'],end
52         if exists('frameflag','local')==1 then opts=[opts,'frameflag=frameflag'],end
53         if exists('axesflag','local')==1 then opts=[opts,'axesflag=axesflag'],end
54         if size(opts,2)<rhs-2 then  error('invalid named arguments'),end
55         
56         execstr('plot2d(xr,feval(xr,f),'+strcat(opts,',')+')')
57         
58 endfunction