I want to plot a bode diagram out of a xcos transfer function. Therefore I tried to execute the example in the help browser in the xcos_simulate command.
The file SCI/modules/xcos/demos/Command.zcos is given there. When I try to run the code which is given in the help, I get an error message.
“Error in post_xcos_simulate: ending simulation.”
The figure is shown, but the bode plot does not start.
What is the problem here? The example in the help should work properly I think? Scilab 2024.1.0
Hello and welcome to Scilab’s Discourse,
The example source seems broken (we are going to fix this, sorry), you can modify it like this:
importXcosDiagram("SCI/modules/xcos/demos/Command.zcos")
// Clear any pre_xcos_simulation;
clear pre_xcos_simulate;
function post_xcos_simulate(%cpr, scs_m, needcompile)
// Retrieve all objects
objs = scs_m.objs;
//Looking for CLR block
for i=1:size(objs)
if objs(i).gui == "CLR" then
clrBlock = objs(i);
break;
end
end
// Check if we found some CLR
if ~exists("clrBlock","local") then
disp("No CLR block found.")
return
end
// Retrieve exprs
exprs = clrBlock.graphics.exprs;
s = poly(0,'s');
num = evstr(exprs(1));
den = evstr(exprs(2));
h = syslin('c', num/den);
// Open new figure then plot Bode
scf(max(winsid())+1);
bode(h, 0.01, 100);
endfunction
xcos_simulate(scs_m, 4);
S.
Yes, now it works. Thanks for your prompt reply.