Can I add line after closing simulink model?

5 visualizzazioni (ultimi 30 giorni)
Chiara
Chiara il 30 Mag 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!

Risposte (1)

Kaustubha Govind
Kaustubha Govind il 30 Mag 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.

Categorie

Scopri di più su Programmatic Model Editing in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by