1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) 2012 - 2016 - Scilab Enterprises
5 // This file is hereby licensed under the terms of the GNU GPL v2.0,
6 // pursuant to article 5.3.4 of the CeCILL v.2.1.
7 // This file was originally licensed under the terms of the CeCILL v2.1,
8 // and continues to be available under such terms.
9 // For more information, see the COPYING file which you should have received
10 // along with this program.
12 function paramfplot2d(f,x,theta,flag,rect)
13 //animated plot of x-->f(x,t) for t=theta(1),theta(2),etc
14 //x=N-vector of x-values
15 //f(x,t)=N-vector of y-values.
16 //f: mapping x,t -> f(x,t) = R^N valued function for x= vector of R^N and t=real number.
17 //f can be a either Scilab function or a dynamically linked routine since
18 // y=f(x,t) is evaluated as y=feval(x(:),t,f). See feval.
19 // Here y should be a column vector.
20 // vector of parameters theta=[theta(1), theta(2),... theta(M)]
21 // Optional parameters
22 //flag = 'yes' (screen is cleared between two consecutive plots).
23 //flag = 'no' (screen is not cleared between two consecutive plots).
25 //rect = "rectangle" [xmin, xmax, ymin, ymax] (1 x 4 real vector),
26 // containing a-priori lower and upper bounds for x and f(t,x).
27 //function y=f(x,t),y=abs(cos(1.5*x+4*t)).*sin(x+10*t),endfunction
28 //x=linspace(0,20*%pi,500);theta=0:0.05:5;
32 deff("y=f(x,t)","y=t*sin(x)")
33 x=linspace(0,2*%pi,50);theta=0:0.05:1;
35 paramfplot2d(f,x,theta);
40 error(msprintf(gettext("%s: Wrong number of input argument(s): At least %d expected.\n"), "paramfplot2d", 3));
44 theta=theta(:).'; // it should be a row-vector
45 if rhs<5 then //compute the data bounds
46 xmin=min(x);xmax=max(x);
49 y=f(x,t); ymin=min(ymin,min(y)); ymax=max(ymax,max(y));
51 rect=[xmin,xmax,ymin,ymax];
53 if rhs<4 then flag="no";end
59 a.data_bounds=matrix(rect,2,2);
61 y=feval(x,theta(1),f);
63 p = gce(); //the polyline handle
68 for k=1:size(theta,"*")
70 y=feval(x,theta(k),f);
76 for k=1:size(theta,"*")
78 plot2d(x,feval(x,theta(k),f))