Can I add line after closing simulink model?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Kaustubha Govind
2013-5-30
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Programmatic Model Editing 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!