Scicos_blocks: clean NonLinear blocks interfaces
[scilab.git] / scilab / modules / scicos_blocks / macros / NonLinear / DLRADAPT_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]=DLRADAPT_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,p,rn,rd,g,last_u,last_y,exprs]=scicos_getvalue("Set block parameters",..
34             ["Vector of p mesh points";
35             "Numerator roots (one line for each mesh)";
36             "Denominator roots (one line for each mesh)";
37             "Vector of gain at mesh points" ;
38             "past inputs (Num degree values)";
39             "past outputs (Den degree values)"],..
40             list("vec",-1,"mat",[-1,-1],"mat",..
41             ["size(%1,''*'')","-1"],"vec","size(%1,''*'')",..
42             "vec","size(%2,2)","vec","size(%3,2)"),exprs)
43
44
45             if ~ok then
46                 break,
47             end
48             m=size(rn,2)
49             [npt,n]=size(rd)
50             if m>=n then
51                 message("Transfer must be strictly proper"),
52             elseif size(rn,1)<>0&size(rn,1)<>size(p,"*") then
53                 message("Numerator roots matrix row size''s is incorrect")
54             else
55                 rpar=[p(:);real(rn(:));imag(rn(:));real(rd(:));imag(rd(:));g(:)]
56                 ipar=[m;n;npt]
57                 model.dstate=[last_u(:);last_y(:)]
58                 model.rpar=rpar
59                 model.ipar=ipar
60                 graphics.exprs=exprs
61                 x.graphics=graphics;
62                 x.model=model
63                 break;
64             end
65         end
66     case "define" then
67         p=[0;1]
68         rn=[]
69         rd=[0.2+0.8*%i,0.2-0.8*%i;0.3+0.7*%i,0.3-0.7*%i]
70         g=[1;1]
71         last_u=[]
72         last_y=[0;0]
73
74         model=scicos_model()
75         model.sim="dlradp"
76         model.in=[1;1]
77         model.out=1
78         model.evtin=1
79
80         model.dstate=[last_u;last_y]
81         model.rpar=[p(:);real(rn(:));imag(rn(:));real(rd(:));imag(rd(:));g(:)]
82         model.ipar=[0;2;2]
83         model.blocktype="d"
84         model.firing=[]
85         model.dep_ut=[%t %f]
86
87         exprs=[sci2exp(p);
88         sci2exp(rn);
89         sci2exp(rd,0);
90         sci2exp(g);
91         sci2exp(last_u);
92         sci2exp(last_y)]
93         gr_i=[]
94         x=standard_define([2 2],model,exprs,gr_i)
95     end
96 endfunction