[Scilab-users] scilab 6.0.0: xcos block with type 5 function
Robin Farine
robin.farine at gmail.com
Tue Aug 15 11:15:33 CEST 2017
Hi,
I am trying to define a custom Xcos block implemented using a Scilab
simulation function (type 5). The block has matrix parameters that I am
trying to store in "model.opar". Whenever I start the simulation, I get the
following error:
Initialisation problem:
scicosim: Wrong type for element #1 of element #15
of argument #4 : A matrix expected.
Interestingly, if I change the simulation function to a native
implementation (type 4), the simulation runs flawlessly.
To illustrate the problem, I added "TBX_OPAR.sci" (see below) to the Xcos
skeleton toolbox.
Any idea?
Thanks,
Robin
function [x, y, typ] = TBX_OPAR(job, arg1, arg2)
x = []; y = []; typ = [];
select job
case "set" then
x = arg1;
model = arg1.model;
graphics = arg1.graphics;
exprs = graphics.exprs;
while %t do
[ok, sim, mat, exprs] = scicos_getvalue(..
"Set no-operation parameters",..
["(0=C, 1=Scilab)"; "Matrix (n*2)"],..
list("vec", 1, "mat", [-1 2]), exprs);
if ~ok then
break,
end //user cancel modification
if size(mat)(2) > 1 then
model.opar = list(double(mat));
x.graphics = graphics;
x.model = model;
if sim == 0 then
model.sim = list("tbx_block_noop", 4);
graphics.style = [..
"blockWithLabel;displayedLabel=""NOOP C"""];
else
model.sim = list("TBX_NOOP_sim", 5);
graphics.style = [..
"blockWithLabel;displayedLabel=""NOOP Scilab"""];
end
graphics.exprs = exprs;
x.graphics = graphics;
x.model = model;
break;
else
message("Matrix requires at least 2 rows.");
end
end
case "define" then
model = scicos_model();
model.sim = list("tbx_block_noop", 4);
model.evtin = 1;
model.blocktype = "d";
model.dep_ut = [%f %f];
model.in = 1;
model.intyp = 1;
model.out = 1;
model.outtyp = 1;
exprs = ["0"; "[0 0; 0.5 1; 1 0]"];
gr_i = [];
x = standard_define([3 2], model, exprs, gr_i);
x.graphics.style = ["blockWithLabel;displayedLabel=""NOOP C"""];
endendfunction
More information about the users
mailing list