How to make an array of pointers to a subset of values in an existing array?
Show older comments
I'm writing a simulation where ClassA is a space inside of which a number of ClassB objects exist. ClassA keeps track of interaction parameters between all of the ClassB objects in large arrays, but the ClassB objects use that information to update themselves,. Depending on some other conditions they don't always update and/or have some unique behavior. This is all to say that I would like a couple of big arrays of information to exist in A, but relevant subsets of that information to be accessible to each B object. So far I've been handling this by storing copies of these relevant subsets in each ClassB object and updating them whenever ClassA updates, but as I have more B objects this is starting to generate a problematic amount of overhead.
So the question: Is there any way to have, say, an nxm array of values in ClassA, and then 1xm arrays of pointers in each of n ClassB objects corresponding to rows of the the nxm ClassA array? I am aware I could make a ClassC object, which inherits handle, and use an array of n such objects in ClassA in lieu of the nxm array itself, then pass relevant handles to ClassB objects, but is there a more direct way to generate pointers to subsets of existing data?
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!