summaryrefslogtreecommitdiff
path: root/modules/graphics/macros/check2dFun.sci
diff options
context:
space:
mode:
authorShashank2017-05-29 12:40:26 +0530
committerShashank2017-05-29 12:40:26 +0530
commit0345245e860375a32c9a437c4a9d9cae807134e9 (patch)
treead51ecbfa7bcd3cc5f09834f1bb8c08feaa526a4 /modules/graphics/macros/check2dFun.sci
downloadscilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.tar.gz
scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.tar.bz2
scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.zip
CMSCOPE changed
Diffstat (limited to 'modules/graphics/macros/check2dFun.sci')
-rwxr-xr-xmodules/graphics/macros/check2dFun.sci64
1 files changed, 64 insertions, 0 deletions
diff --git a/modules/graphics/macros/check2dFun.sci b/modules/graphics/macros/check2dFun.sci
new file mode 100755
index 000000000..36d7569f0
--- /dev/null
+++ b/modules/graphics/macros/check2dFun.sci
@@ -0,0 +1,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