Creation of variable and graphical handles programmatically

Sébastien Bihorel pomchip at free.fr
Mon Oct 12 13:28:15 CEST 2009


Dear Scilab users,

I wonder how one can create variables or graphical handles programmatically
and assign values to them at the same time. For instance, consider the
following attempted code where nstates 'sub-plots' should be created within
a figure (please, note that I don't want to use the subplot function for
some other reason). This syntax is obviously wrong, according to the Scilab
error message, but I do not know how to fix that. Any help would be greatly
appreciated.

Sebastien


///////////////////
figure()

nstates=6;
ndim= ceil(sqrt(nstates));
multi=pmodulo((1:nstates)-1,ndim);
margin=0.05;

for (j=1:nstates)
    eval('g' + string(j) + '=newaxes()')
    eval('g' + string(j) + '.axes_bounds=[' + string(multi/ndim) + ',' +...
          string(marg + multi*(1-marg)/ndim) + ',' +...
          string(1/dim) + ',' +...
          string((1-marg)/ndim) + ']');
end

/////////////// Scilab error message
%h=g1=newaxes();
       !
at line       3 of function %eval                    called by :
line    17 of function eval                     called by :
eval('g' + string(j) + '=newaxes();')
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20091012/0a1ba5e4/attachment.htm>


More information about the users mailing list