~ubuntu-branches/ubuntu/hoary/scilab/hoary

« back to all changes in this revision

Viewing changes to macros/scicos_blocks/Linear/DLR_f.sci

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2005-01-09 22:58:21 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050109225821-473xr8vhgugxxx5j
Tags: 3.0-12
changed configure.in to build scilab's own malloc.o, closes: #255869

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function [x,y,typ]=DLR_f(job,arg1,arg2)
 
2
// Copyright INRIA
 
3
x=[];y=[];typ=[]
 
4
select job
 
5
case 'plot' then
 
6
  standard_draw(arg1)
 
7
case 'getinputs' then
 
8
  [x,y,typ]=standard_inputs(arg1)
 
9
case 'getoutputs' then
 
10
  [x,y,typ]=standard_outputs(arg1)
 
11
case 'getorigin' then
 
12
  [x,y]=standard_origin(arg1)
 
13
case 'set' then
 
14
  x=arg1;
 
15
  graphics=arg1.graphics;exprs=graphics.exprs
 
16
  model=arg1.model;
 
17
  x0=model.dstate;ns=prod(size(x0));
 
18
  z=poly(0,'z')
 
19
  while %t do
 
20
    [ok,num,den,exprs]=getvalue('Set discrete SISO transfer parameters',..
 
21
        ['Numerator (z)';
 
22
         'Denominator (z)'],..
 
23
        list('pol',1,'pol',1),exprs)
 
24
    if ~ok then break,end
 
25
    if degree(num)>degree(den) then
 
26
      message('Transfer must be proper')
 
27
      ok=%f
 
28
    end
 
29
    if ok then
 
30
      H=cont_frm(num,den)
 
31
      [A,B,C,D]=H(2:5);
 
32
      graphics.exprs=exprs;
 
33
      [ns1,ns1]=size(A)
 
34
      if ns1<=ns then
 
35
        x0=x0(1:ns1)
 
36
      else
 
37
        x0(ns1,1)=0
 
38
      end
 
39
      rpar=[A(:);
 
40
            B(:);
 
41
            C(:);
 
42
            D(:)]
 
43
      model.dstate=x0
 
44
      model.rpar=rpar
 
45
      if norm(D,1)<>0 then
 
46
        mmm=[%t %f];
 
47
      else
 
48
        mmm=[%f %f];
 
49
      end
 
50
      if or(model.dep_ut<>mmm) then 
 
51
          model.dep_ut=mmm,end
 
52
      x.graphics=graphics;x.model=model
 
53
      break
 
54
    end
 
55
  end
 
56
  x.model.firing=[] //compatibility
 
57
case 'define' then
 
58
  x0=0;A=-1;B=1;C=1;D=0;
 
59
  exprs=['1';'1+z']
 
60
  
 
61
  model=scicos_model()
 
62
  model.sim='dsslti'
 
63
  model.in=1
 
64
  model.out=1
 
65
  model.evtin=1
 
66
  model.dstate=x0(:)
 
67
  model.rpar=[A(:);B(:);C(:);D(:)]
 
68
  model.blocktype='d'
 
69
  model.dep_ut=[%f %f]
 
70
 
 
71
  gr_i=['xstringb(orig(1),orig(2),[''num(z)'';''den(z)''],sz(1),sz(2),''fill'')';
 
72
        'xpoly([orig(1)+.1*sz(1),orig(1)+.9*sz(1)],[1,1]*(orig(2)+sz(2)/2))']
 
73
  x=standard_define([2.5 2.5],model,exprs,gr_i)
 
74
end
 
75
endfunction