File: _check2dFun.sci

package info (click to toggle)
scilab-plotlib 0.41-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 3,196 kB
  • sloc: xml: 3,308; makefile: 15
file content (51 lines) | stat: -rw-r--r-- 1,251 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
function [nArgOut,vectInput]=_check2dFun(funName,func,X)

// In this function we determine wether the function 'func'
// has the syntax [y]=func(x) or [x,y]=func(t). 
// We also test if the function accepts vector input
// arguments.
//
// This allow to understand in a 2d plot function (plot)
// if the user has requested a 2d plot of a parametric or
// non-parametric curve. 

// First We get the two strings in and out containing the
// names of input and output arguments :

[out,in,text]=string(func);

nArgOut=max(size(out));
nArgIn=max(size(in))

if nArgIn~=1
   _error(sprintf('%s : function must accept two input arguments',funName));
end

if nArgOut~=1 & nArgOut~=2
   _error(sprintf('%s : function must have 1 or 2 output arguments',funName));
end

// Now we test if func accepts vector inputs (we test with the X,Y
// pair provided by the user)

if nArgOut==1;

   ierr=execstr('yf=func(X)','errcatch');
   if ierr==0
      vectInput=(and(size(yf)==size(X)));
   else
      vectInput=%F;
   end

elseif nArgOut==2
  
  // now we test if func accepts vector inputs (as above)
  
  xf=[];yf=[];
  ierr=execstr('[xf,yf]=func(X)','errcatch');
 
  vectInput=(ierr==0 & and([size(xf)==size(yf) ... 
			    size(yf)==size(X)]));
end

endfunction