Interfacing function
eng


NOISEBLK_f

File content


//NOISEBLK_f Scicos Gaussian Random Generator
//Classical interface function ver1.0 - scilab-3
//7 juillet 2004  Author : - IRCOM GROUP - A.Layec
function [x,y,typ]=NOISEBLK_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;model=arg1.model;
   exprs=graphics.exprs;

   while %t do

      text=['Set Scicos Gaussian Noise Generator']
      [ok,ny,sig,moy,seed,typ,exprs]=getvalue(text,...
      ['Size of outputs';'sigma';'mean';'seed';'Type'],...
      list('vec',1,'vec',-1,'vec',-1,'vec',1,'vec',1),exprs)

      if ~ok then break,end;
      sz_out=size(ny,'*');
      //if sz_out>2 then
      // ok=%f
      // message('Vector of size of outputs must have a size <= 2')
      //else 
      if ok then
          graphics.exprs=exprs
          model.in=[]    
          if(typ==2) then
          [model,graphics,ok]=check_io(model,graphics,[],[ny;ny],[1],[])
           model.out=[ny;ny]
          else
           [model,graphics,ok]=check_io(model,graphics,[],[ny],[1],[])
           model.out=ny;
          end
          model.dstate=[]
          model.ipar=[int(seed);typ]
          model.rpar=[sig(:);moy(:)]
          x.graphics=graphics;x.model=model
          break;
      end
   end

case 'define' then
  ny=64
  sig=0.1*ones(ny,1)
  moy=0*ones(ny,1)
  seed=int(rand()*1e8)
  typ=0

  model=scicos_model()
  model.sim=list('noiseblk',4)
  model.in=[]
  model.out=ny;
  model.evtin=[1]
  model.evtout=[]
  model.dstate=[]
  model.rpar=[sig(:);moy(:)]
  model.ipar=[seed;typ]
  model.blocktype='d'
  model.firing=[]
  model.dep_ut=[%f %f]

  gr_i=['txt=[''Random'';''Generator''];';
        'xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'');'
        'xset(''font'',5,1)'
        'txt=''Muller Law'';'
        '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;']
  exprs=[string(ny),'0.1*ones(64,1)','0*ones(64,1)',string('int(rand()*1e8)'),string(typ)]
  x=standard_define([2 2],model,exprs,gr_i)
end
endfunction