//GAUSSF_c Scicos Gaussian Filter block //Classical interface function ver1.0 - scilab-4.1 //17 Avril 2007 - INRIA - Author : A.Layec function [x,y,typ]=GAUSSF_c(job,arg1,arg2) // Copyright INRIA 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; model=arg1.model; graphics=arg1.graphics; exprs=graphics.exprs; while %t do [ok,insz,ne,bt,nb_coef,gain,herit,plot_rep,exprs]=... getvalue('Set Gaussian Filter',... ['Size of input vectors';... 'Samples per symbol';... 'BT Factor';... 'Length of impulse response';... 'Filter Gain';... 'Inherit (no:0, yes:1)';... 'Plot impulse response (0:no or winid)'],... list('vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',1,'vec',1),exprs); if ~ok then break,end; //value checking if find(insz<0)<>[] then message('Size of input vectors must be >0') ok=%f end if ok then if find(bt<0|bt>1)<>[] then message('BT factor must be >0 and <1') ok=%f end end //cross size checking if ok then if ~and(size(ne)==size(bt)&size(bt)==size(gain)&size(bt)==size(nb_coef)) then message(['Frequency sampling vector, vector of BT, '+... 'vector of Gain and'; 'vector ''length of impulse response'' must have the same size']); ok=%f else nfir=size(insz,'*'); //nb filtres nrep=size(bt,'*'); //nb de rep. impuls. if (nfir<>1&nrep<>1&nfir<>nrep) then message(['Number of impulse response is different from 1 and is different from '+... 'number of input vectors';'Please check.']); ok=%f elseif (nfir==1)&(nrep>1) message(['You have defined many impulse response for only one'; 'input vector. Please check.']); ok=%f else ne=ne(:) bt=bt(:) nb_coef=nb_coef(:) gain=gain(:) if plot_rep>0 then for j=1:nrep if execstr('puls=filter_tap(3,nb_coef(j),ne(j),bt(j),gain(j))','errcatch')<>0 then message(['Bad parameters in the computation of the impulse response'; 'Please try another set of parameters for filter '+string(j)]) ok=%f break end win=xget("window") xset("window",int(plot_rep+j-1)) xset("wdim",300,200) xbasc() plot2d3(1:nb_coef(j),puls,,"111",,rect=[0,min(puls),nb_coef(j),max(puls)]); xset("window",win); end end end end end if ok then model.in=sum(insz); model.out=sum(insz); //model.dstate=zeros(sum(nb_coef),1); model.dstate=[]; model.ipar=[nfir;nrep;3*ones(nrep,1);ne(:);nb_coef(:);insz(:)]; //model.rpar=pulse(:); model.rpar=[bt(:);gain(:)]; graphics.exprs=exprs; sz=model.in; if herit==1 then [model,graphics,ok]=check_io(model,graphics,[sz],[sz],[],[]); else [model,graphics,ok]=check_io(model,graphics,[sz],[sz],1,[]); end x.model=model x.graphics=graphics; break end end case 'define' then insz=1 ne=12 typ=3 nb_coef=4*ne*1 + 1 bt=0.4 gain=1 herit=0 plot_rep=0 nu=sum(insz) //taile du port d'entrée nfir=size(insz,'*'); //nbre de filtre nrep=size(bt,'*'); //nbre de rep. impuls. model=scicos_model() model.sim=list('com_filter',4) model.in=nu model.out=nu model.evtin=1 model.evtout=[] //model.dstate=zeros(sum(nb_coef),1) model.dstate=[] model.ipar=[nfir;nrep;typ(:);ne(:);nb_coef(:);insz(:)] model.rpar=[bt(:);gain(:)] model.blocktype='d' model.firing=[] model.dep_ut=[%t %f] exprs=[string(insz),string(ne),string(bt),string(nb_coef),string(gain),... string(herit),string(plot_rep)] gr_i=['thick=xget(''thickness'');'; 'pat=xget(''pattern'');'; 'fnt=xget(''font'');'; 'a=orig(1)+sz(1)/10;'; 'b=a+sz(1)*8/10;'; 'd=orig(2)+(1-1/10)*sz(2);'; 'c=d-sz(2)*8/10;'; 'xset(''thickness'',1.5);'; 'yy1=[0.000,0.001,0.0027,'+.. '0.0066,0.0147,0.0305,'+.. '0.0593,0.1072,0.1809,'+.. '0.2848,0.418,0.572,'+.. '0.730,0.87,0.965];' 'yy=[yy1,1,yy1($:-1:1)];' 'xx=(a:(b-a)/30:b);' 'xpoly(xx,(yy)*(d-c)+c);' 'txt=''Gauss'';' '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.5 2],model,exprs,gr_i) end endfunction