Borrar filtros
Borrar filtros

Can I add line after closing simulink model?

1 visualización (últimos 30 días)
Chiara
Chiara el 30 de Mayo de 2013
I have written code to build a simulink model. Since I want to add line afterwards, I use two variables, one of them is an array containing all the handles taken from add_block function, the second variable is used to store structs taken from get_param(handle,'PortHandles').
It's like this:
H=[H;addblock()] % array
P=[P;get_param(H(length(H)),'PortHandles')] %array of struct variables
When it ends to add all the blocks, the model is saved and closed. then I try to write commands from Command Window:
e.g. open_system('sas') add_line('sas',P(1).RConn(1),P(2).LConn(1))
It gives an error:
??? Invalid Simulink port handle
I don't have this error, if I run add_line before saving and closing the script, i.e while my script is still running.
Can you understand why? P and H are readable in Workspace even after I close the model!

Respuestas (1)

Kaustubha Govind
Kaustubha Govind el 30 de Mayo de 2013
I don't think the handles are valid once the model is closed and re-opened. You need to use find_system to grab the handles again.

Categorías

Más información sobre Programmatic Model Editing en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by