scs_m.props.context=[ 'F_cpf = 20e6;' 'T_cpf = 1/F_cpf;' 'sig_ref=(2*%pi*0.01/100)' 'Fo = 2.045e9;' 'To = 1 / Fo;' 'wo=2*%pi * Fo;' 'kv = 100.5e6;' 'alpha=6.91e9;' 'beta2=0.15;' 'Fd=2.45e9;' 'N=int(Fd/F_cpf)' 'j_vco=2e6/N;' 'Nsampl = 16;' 'Tsampl = T_cpf/Nsampl;' 'Fsampl = 1 / Tsampl;' 'Icp = 5e-3;' 'Ileak=10e-6;' 'Ileak_sig=1e-12;' 'fn=F_cpf/180;' 'phi=%pi/4;' '[tau1,tau,tau2]=calcul_3eme_ordre(fn,phi,kv*2*%pi,Icp,N);' 's=poly(0,''s'');' 'num=1+tau1*s;' 'den=tau*s*(1+tau2*s);' 'Nsav=2^21+2^20' 'Tse=Tsampl' 'Tacqui=1e-4' 'Tfin=Tacqui+Nsav*Tse' ];
//Define simulation name sim_name='synthe_int_sim'; //Define simulation path sim_path='synthe_int_sim'; //Load scicos diagram load(MODNUM+'/simu/'+sim_path+'/'+sim_name+'.cos'); //Tests for scicos version ierr = execstr('current_version=get_scicos_version()','errcatch') if ierr==0 then //scilab > 4.1x //check version if type(scs_m)==17 then if find(getfield(1,scs_m)=='version')<>[] then if scs_m.version<>'' then scicos_ver=scs_m.version end end end if current_version<>scicos_ver then scs_m=do_version(scs_m,scicos_ver) end end //Define context exec(MODNUM+'/simu/'+sim_path+'/'+sim_name+'_ctxt.sce'); context=scs_m.props("context");execstr(context); //Define Simulation end time scs_m.props.tf=Tfin; //Define other variables //Open Log file u_log=mopen(MODNUM+'/simu/'+sim_path+'/'+sim_name+'.log','a'); //Set flag (for display saved information in scilab window) flag=1; //Save inital state of simulation in Log file wlog_init(u_log,flag); //Save context in log file wlog_ctxt(u_log,flag); //Loop for iterative simulation j=1; //Save and display begin simulation date j wlog_bst(u_log,j,flag); //substitue context variable to be sweep //scs_m.props.context=subst_ctxt('varname','varname='); //Initialise Info and %scicos_context variable //if exists('Info')==0 then clear Info; Info=list(); //end //if exists('%scicos_context')==0 then %scicos_context=struct(); end clear %scicos_context; %scicos_context=struct(); //Do simulation with scicos_simulate Info=scicos_simulate(scs_m,Info,%scicos_context); //Load result myvar=return_state_block(Info,"z_buf"); //Save and display util variable //wlog_sv(u_log,tlist(['varname'],varvalue),flag); //Save and Disp final simulation date j wlog_fst(u_log,j,flag); //post-processed result //Save and display post-processed vector(matrix) //wlog_psv(u_log,tlist(['varname'],varvalue,flag); //Close final state of simulation in Log file wlog_final(u_log,flag); //close log file mclose(u_log); plot_spectre2(myvar(1)(1:Nsav),Tsampl,Tacqui,N*F_cpf,0.9e6,10,0); plot_spectre2(myvar(1)(1:Nsav),Tsampl,Tacqui,N*F_cpf,0.5e6,11,1);