Is dynamic allocation of structures allowed?
古いコメントを表示
I am writing a particle simulator, each particle has the following structure:
myFriend.name % string of unknown length (until loaded)
myFriend.number % int
myFriend.position % 1x3 vector double
myFriend.hisFriend % array of structures of type myFriend, length variable
During the simulation the number of myFriend structures varies, as well as the number of hisFriend structures for each myFriend structure that is present at that time.
Is it kosher to allocate these "on the fly"? How does one deallocate them? Is deallocation necessary to prevent memory leaks? Sorry for the elementary nature of these questions. TIA!
回答 (1 件)
Sean de Wolski
2013 年 11 月 19 日
0 投票
Can you allocate on the fly:
- Yes. Use dynamic fieldnames to create additional fields as necessary
Do I need to worry about memory leaks and cleanup?
- No. MATLAB takes care of this for you!
カテゴリ
ヘルプ センター および File Exchange で Adaptive Control についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!