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

« back to all changes in this revision

Viewing changes to macros/scicos_blocks/NonLinear/LOOKUP_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]=LOOKUP_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;rpar=model.rpar;
 
17
  n=size(rpar,'*')/2
 
18
  xx=rpar(1:n);yy=rpar(n+1:2*n)
 
19
  while %t do
 
20
    old_win=xget('window')
 
21
    win=maxi(winsid())+1
 
22
    xset('window',win);xsetech([0 0 1 1])
 
23
    [xx,yy,ok]=edit_curv(xx,yy,'axy')
 
24
    xdel(win)
 
25
    xset('window',old_win)
 
26
    if ~ok then break,end
 
27
    n=size(xx,'*')
 
28
    if or(xx(2:n)-xx(1:n-1)<=0) then
 
29
      message('You have not defined a function')
 
30
      ok=%f
 
31
    end
 
32
    if ok then
 
33
      model.rpar=[xx(:);yy(:)]
 
34
      x.graphics=graphics;x.model=model
 
35
      break
 
36
    end
 
37
  end
 
38
case 'define' then
 
39
  model=scicos_model()
 
40
  model.sim='lookup'
 
41
  model.in=1
 
42
  model.out=1
 
43
  model.rpar=[-2;-1;1;2;-1;1;-1;1]
 
44
  model.blocktype='c'
 
45
  model.dep_ut=[%t %f]
 
46
 
 
47
  gr_i=['rpar=model.rpar;n=size(rpar,''*'')/2;';
 
48
    'thick=xget(''thickness'');xset(''thickness'',2);';
 
49
    'xx=rpar(1:n);yy=rpar(n+1:2*n);';
 
50
    'mnx=mini(xx);xx=xx-mnx*ones(xx);mxx=maxi(xx);';
 
51
    'xx=orig(1)+sz(1)*(1/10+(4/5)*xx/mxx);';
 
52
    'mnx=mini(yy);yy=yy-mnx*ones(yy);mxx=maxi(yy);';
 
53
    'yy=orig(2)+sz(2)*(1/10+(4/5)*yy/mxx);';
 
54
    'xpoly(xx,yy,''lines'');';
 
55
    'xset(''thickness'',thick);']
 
56
  x=standard_define([2 2],model,[],gr_i)
 
57
end
 
58
endfunction