Interfacing function
eng


TRAPINTEGRAL_f

File content


//TRAPINTEGRAL_f Scicos vector intgerator by Trapezoidal method
//Classical interface function ver1.0 - scilab-2.7
//17 novembre 2003 - IRCOM GROUP - Author : A.Layec
function [x,y,typ]=TRAPINTEGRAL_f(job,arg1,arg2)
x=[];y=[];typ=[]
select job
case 'plot' then
  standard_draw(arg1)
case 'getinputs' then
  [x,y,typ]=standard_inputs(arg1)
case 'getoutputs' then
  [x,y,typ]=standard_outputs(arg1)
case 'getorigin' then
  [x,y]=standard_origin(arg1)
case 'set' then
  x=arg1
  graphics=arg1.graphics;exprs=graphics.exprs
  model=arg1.model;
  while %t do
   text=['Set discrete integral parameters';'(trapezoidal method)']
   [ok,step,x0_in,x0_out,exprs]=getvalue(text,...
      ['Step';'Initial input state';'Initial output sate'],...
      list('vec',1,'vec',-1,'vec',-1),exprs)

    nu=size(x0_in,'*')
    if ~ok then break,end
    if size(x0_in)==size(x0_out) then
         nu=size(x0_in,'*')
         if ok then
           graphics.exprs=exprs;
           model.in=nu
           model.out=nu
           model.rpar=step
           model.dstate=[x0_out(:);x0_in(:)]
           model.dep_ut=[%t %f] //for compatibility
           x.graphics=graphics;x.model=model
           break
         end
    else
         message('Vector Initial input state and vector Initial output sate must have the same size');
    end
  end

case 'define' then
  x0_in=0
  x0_out=0
  step=1
  nu=1

  model=scicos_model()
  model.sim=list('int_trap',2)
  model.in=nu
  model.out=nu
  model.evtin=1
  model.evtout=[]
  model.rpar=step
  model.dstate=[x0_out(:);x0_in(:)]
  model.blocktype='d'
  model.dep_ut=[%t %f]

  exprs=[string(step);string(x0_in);string(x0_out)]
  gr_i=['thick=xget(''thickness'')'
        'pat=xget(''pattern'')'
        'fnt=xget(''font'')'
        'xpoly(orig(1)+[0.7;0.62;0.549;0.44;0.364;0.291]*sz(1),orig(2)+[0.947;0.947;0.884;0.321;0.255;0.255]*sz(2),"'lines"')'
        'txt=''Trapezoidal'';'
        'style=5;'
        'rectstr=stringbox(txt,orig(1),orig(2),0,style,1);'
        'w=(rectstr(1,3)-rectstr(1,2))*%zoom;'
        'h=(rectstr(2,2)-rectstr(2,4))*%zoom;'
        'xstringb(orig(1)+sz(1)/2-w/2,orig(2)-h-4,txt,w,h,''fill'');'
        'e=gce();'
        'e.font_style=style;'
        'xset(''thickness'',thick)'
        'xset(''pattern'',pat)'
        'xset(''font'',fnt(1),fnt(2))'
       ]
  x=standard_define([2 2],model,exprs,gr_i)
end
endfunction