//UPSMPL_f Scicos upsample block //Classical interface function ver1.0 - scilab-3 //29 janvier 2004 Author : - IRCOM GROUP - A.Layec function [x,y,typ]=UPSMPL_f(job,arg1,arg2) x=[];y=[];typ=[] select job case 'plot' then nech=arg1.model.ipar(1); 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 Upsample block'] [ok,nu,nech,init,typ,herit,exprs]=getvalue(text,... ['Size of inputs';'Upsample factor';'Offset';... 'Type of upsample';'Inherit (no:0, yes:1)'],... list('vec',1,'vec',1,'vec',1,'vec',1,'vec',1),exprs) if ~ok then break,end; //test if ~is_int(nu) then message('The size of inputs must be integer.') ok=%F elseif ~is_int(nech) then message('The downsample factor must be integer.') ok=%F elseif ~is_int(init) then message('The offset must be integer.') ok=%F end if find(typ==[0:3])==[] then message('Type of upsample must be 0,1,2 or 3.') ok=%F end if ok then //ATTENTION graphics.gr_i(1)(9)='xstring(orig(1)+0.55*sz(1),orig(2)+0.4*sz(2),string(nech(1)),0,0)' if (typ==0|typ==1) then ny=nu elseif (typ==2|typ==3) then ny=nu*nech end if herit==1 then [model,graphics,ok]=check_io(model,graphics,nu,ny,[],[]) else [model,graphics,ok]=check_io(model,graphics,nu,ny,1,[]) end graphics.exprs=exprs model.in=nu model.out=ny model.dstate=init model.ipar=[nech;typ] x.graphics=graphics;x.model=model break; end end case 'define' then nu=1 herit=1 nech=8 ny=nu typ=0 init=0 model=scicos_model() model.sim=list('surecht',4) model.in=nu model.out=ny model.evtin=[] model.evtout=[] model.dstate=init model.rpar=[] model.ipar=[nech;typ] model.blocktype='d' model.firing=[] model.dep_ut=[%t %f] gr_i=['thick=xget(''thickness'')' 'pat=xget(''pattern'')' 'fnt=xget(''font'')' 'l=0.15;h=0.2'; 'x0=0.31;y0=0.15;y1=0.6' 'x1=x0-l/2;x2=x0+l/2;y2=y1+h' 'xpoly(orig(1)+[x0;x0]*sz(1),orig(2)+[y0;y1]*sz(2),""lines"")' 'xfpoly(orig(1)+[x1;x2;x0]*sz(1),orig(2)+[y1;y1;y2]*sz(2),1)' 'xstring(orig(1)+0.55*sz(1),orig(2)+0.4*sz(2),""N"",0,0)' 'xset(''thickness'',thick)' 'xset(''pattern'',pat)' 'xset(''font'',fnt(1),fnt(2))' ] exprs=[string(nu),string(nech),string(init),string(typ),string(herit)] x=standard_define([2 2],model,exprs,gr_i) end endfunction //X est une matrice de réels //tt est un boolean function tt=is_int(X) Y=matrix(X,size(X,'*'),1); Z=int(X); tt=%t; for i=1:size(Y,1) if (Z(i)-Y(i))<>0 then tt=tt&%f; else tt=tt&%t; end end endfunction