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
52
53
54
55
56
57
58
59
60
61
62
63
64
|
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) INRIA
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
function [nArgOut,vectInput]=check2dFun(funName,func,X,current_figure,cur_draw_mode)
// 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
warning(sprintf("%s : function must accept two input arguments",funName));
ResetFigureDDM(current_figure, cur_draw_mode)
return;
end
if nArgOut~=1 & nArgOut~=2
warning(sprintf("%s : function must have 1 or 2 output arguments",funName));
ResetFigureDDM(current_figure, cur_draw_mode)
return;
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
|