~ubuntu-branches/ubuntu/karmic/scilab/karmic

« back to all changes in this revision

Viewing changes to macros/xdess/fplot2d.sci

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2002-03-21 16:57:43 UTC
  • Revision ID: james.westby@ubuntu.com-20020321165743-e9mv12c1tb1plztg
Tags: upstream-2.6
ImportĀ upstreamĀ versionĀ 2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function []=fplot2d(xr,f,style,strf,leg,rect,nax,void)
 
2
// 2D plot of function f : a Scilab function or the name (as a string)
 
3
//  of a dynamically linked function.
 
4
// Enter fplot2d() for an example.
 
5
// deff('<y>=f(x)','y=sin(x)+cos(x)');
 
6
// fplot2d(f,0:0.1:%pi);
 
7
//!
 
8
// Copyright INRIA
 
9
[lhs,rhs]=argn(0)
 
10
if rhs<=0,
 
11
  s_mat=['deff(''[y]=f(x)'',''y=sin(x)+cos(x)'');';
 
12
         'fplot2d(0:0.1:%pi,f);'];
 
13
  write(%io(2),s_mat);execstr(s_mat);
 
14
  return;
 
15
end;
 
16
if type(xr)=='10' then // logflag passed first
 
17
  error('First argument must be the discretization of x')
 
18
elseif rhs < 2 then 
 
19
  error('at least 2 input arguments required')
 
20
end
 
21
//handling optionnal arguments
 
22
opts=[]
 
23
if exists('style','local')==1 then opts=[opts,'style=style'],end
 
24
if exists('strf','local')==1 then opts=[opts,'strf=strf'],end
 
25
if exists('leg','local')==1 then opts=[opts,'leg=leg'],end
 
26
if exists('rect','local')==1 then opts=[opts,'rect=rect'],end
 
27
if exists('nax','local')==1 then opts=[opts,'nax=nax'],end
 
28
if exists('logflag','local')==1 then opts=[opts,'logflag=logflag'],end
 
29
if exists('frameflag','local')==1 then opts=[opts,'frameflag=frameflag'],end
 
30
if exists('axesflag','local')==1 then opts=[opts,'axesflag=axesflag'],end
 
31
if size(opts,2)<rhs-2 then  error('invalid named arguments'),end
 
32
execstr('plot2d(xr,feval(xr,f),'+strcat(opts,',')+')')