* Bug 16365 fixed: median(m,'r'|'c') was wrong after 5dc990
[scilab.git] / scilab / modules / scicos_blocks / macros / NonLinear / INTRP2BLK_f.sci
1 //  Scicos
2 //
3 //  Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 //
19 // See the file ../license.txt
20 //
21
22 function [x,y,typ]=INTRP2BLK_f(job,arg1,arg2)
23     x=[];
24     y=[];
25     typ=[];
26     select job
27     case "set" then
28         x=arg1;
29         graphics=arg1.graphics;
30         exprs=graphics.exprs
31         model=arg1.model;
32         while %t do
33             [ok,a,b,c,exprs]=scicos_getvalue(..
34             _("Set Interpolation block parameters"),..
35             _(["X coord.";"Y coord.";"Z values"]), ..
36             list("vec",-1,"vec",-1,"mat",[-1,-1]),exprs)
37             if ~ok then
38                 break,
39             end
40             if size(a,"*") <> size(c,"c") | size(b,"*") <> size(c,"r") then
41                 message(_("X, Y, Z: incompatible sizes"))
42             elseif min(a(2:$)-a(1:$-1)) <=0 | min(b(2:$)-b(1:$-1)) <=0 then
43                 message(_("X and Y must be strictly increasing"))
44             else
45                 if ok then
46                     graphics.exprs=exprs
47                     model.rpar=[a(:);b(:);c(:)]
48                     model.ipar=[size(a,"*");size(b,"*")]
49                     x.graphics=graphics;
50                     x.model=model
51                     break
52                 end
53             end
54         end
55     case "define" then
56         a=[0;1];
57         b=[0;1];
58         c=[0 1;1 2]
59         model=scicos_model()
60         model.sim=list("intrp2",1)
61         model.in=[1;1]
62         model.out=1
63         model.rpar=[a;b;c(:)]
64         model.ipar=[2;2]
65         model.blocktype="c"
66         model.dep_ut=[%t %f]
67         exprs=[strcat(sci2exp(a));strcat(sci2exp(b));strcat(sci2exp(c,0))]
68         gr_i=[]
69         x=standard_define([3 2],model,exprs,gr_i)
70     end
71 endfunction