<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: arial,helvetica,sans-serif; font-size: 12pt; color: #000000'>Dear Scilab users,<br><br>I am running a simple electrical model in xcos (see attached). This model reads a .csv input file and outputs a variable to the workspace. The model works fine when I compile it and run it by using the menus in xcos.<br><br>What I would like is to run it in batch mode from Scilab in order optimise the model parameters.<br><br>My plan is to use <i>xcos_simulate</i> to compile the diagram, to modify the <i>cpr</i> variable generated by the compilation (to change the model parameters) and than to simulate the model with <i>scicosim</i>.<br><br>The problem is that calling the <i>cpr</i> variable after the compilation results in kind of "freezing" the workspace.<br><br>- The variable browser shows "N/A" for all the variables (from image 1 to image 2 attached)<br>- Calling <i>cpr</i> does not give any result (image 3 attached)<br><br>Does anyone has any idea of what is happening?<br><br>I am using Scilab 5.4.1.<br><br>My code is as follows:<br><br><font size="2">// parameters<br>data=csvRead('input.csv',';');<br>input_current=evstr(data(:,1));<br>size1=length(input_current);<br><br>C=1/10000;<br>R=12900;<br><br>T=0.0001; // timestep<br><br>time=[0:T:(size1-1)*T]'; // in s<br><br>end_time=time($)+T; // end time in s<br><br>// loading Xcos functions<br>loadScicos;<br>loadXcosLibs();<br>exec(loadpallibs,-1);<br><br>// loading model<br>importXcosDiagram('graphic_model.xcos')<br><br>// compilation: scs_m is the result of the import,<br>xcos_simulate(scs_m,4) // '4' is to perform compilation<br><br>tf=end_time;<br><br>atol=1.e-8;<br>rtol=1.e-9;<br>ttol=1.e-10;<br>deltat=tf;<br>scale=0;<br>hmax=0;<br><br>tol=[atol,rtol,ttol,deltat,scale,hmax];<br><br>// PROBLEM COMES WHEN EXECUTING NEXT LINE<br><br>state=cpr.state; // cpr variable came from the compilation<br>sim=cpr.sim;<br><br>cpr.sim.rpar(5)=T; // timestep<br>cpr.sim.rpar(5)=0; // initialisation<br>cpr.sim.rpar(7)=R; // resistance<br>cpr.sim.rpar(8)=C; // capacitor<br><br>// initialisation<br>[state,t]=scicosim(state,0,tf,sim,'start',tol);<br>// run<br>[state,t]=scicosim(state,t,tf,sim,'run',tol)<br>//end<br>[state,t]=scicosim(state,t,tf,sim,'finish',tol);<br><br>graph_voltage=graph_voltage.values; // output variable</font><br><br>Thanks a lot for your help.<br><br><span class="addrBubble-selected" style="position: static; overflow: visible;" id="DWT143"><span><span class="addrBubbleHide" id="DWT143_select"></span></span></span>Best regards,<br><br><div><span name="x"></span><font size="1"><font size="2">Romain</font></font><br></div></div></body></html>