Borrar filtros
Borrar filtros

Set multiple attributes in entity generator block

4 visualizaciones (últimos 30 días)
Marco Fanti
Marco Fanti el 18 de Dic. de 2018
Editada: Krishna Akella el 11 de Jul. de 2024 a las 6:58
Hello,
I am trying to build a SimEvents model from code.
I need to create multiple attributes for my entity generator block but for the add_block command I am only able to set one of them.
This is the code for my EntityGenerator creator:
add_block('built-in/entitygenerator',[sys '/eg'],'Position',pos,'TimeSource','MATLAB action', 'IntergenerationTimeAction','dt=exprnd(2);','entitytype','structured','AttributeName','Path' , 'AttributeInitialValue' ,'0' );

Respuesta aceptada

Krishna Akella
Krishna Akella el 19 de Dic. de 2018
Hi Marco,
The different attribute names and their initial values are delimited by the pipe symbol. For example if you want to add two attributes called 'Path1' and 'Path2' with initial values '0' and '1', you can use the following:
add_block('built-in/entitygenerator',[sys '/eg'],'Position',pos,'TimeSource','MATLAB action', 'IntergenerationTimeAction','dt=exprnd(2);','entitytype','structured','AttributeName','Path1|Path2' , 'AttributeInitialValue' ,'0|1' );
- Krishna

Más respuestas (1)

Krishna Akella
Krishna Akella el 11 de Jul. de 2024 a las 6:57
Editada: Krishna Akella el 11 de Jul. de 2024 a las 6:58
Also, there is an artificial limitation in the UI of the Entity Generator block, that does not allow adding more than 31 attributes. One way to overcome this is by setting the block parameters from the MATLAB command line. For example, the following code adds 156 attributes to the entity generator block.
a = ''
b = ''
for i=1:155
a = [a 'a' num2str(i) '|'];
b = [b '1|'];
end
a = [a 'a156'];
b = [b '1'];
% gcb is the entity generator block, which must be selected in the editor
set_param(gcb, 'AttributeInitialValue', b, 'AttributeName', a);
After this, one can open the 'Entity Generator' block dialog and edit the attribute names and initial values as they want.
- Krishna

Categorías

Más información sobre Discrete-Event Simulation en Help Center y File Exchange.

Productos


Versión

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by