Can I add line after closing simulink model?
1 view (last 30 days)
Show older comments
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!
0 Comments
Answers (1)
Kaustubha Govind
on 30 May 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.
0 Comments
See Also
Categories
Find more on Programmatic Model Editing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!