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!