In Matlab I have three classes. The parent class is an abstract class named Zone. It has two child classes that inherit from it. They are IZone and SZone.
I have a fourth class called System that is supposed to have an array of Zone objects. However, when I create the array and pass in an SZone object, the array becomes an array of type SZone and Matlab won't let me add any IZone objects to it.
If I add an IZone and SZone at the same time, it creates an array of type Zone. But I never actually do this. I only add one zone at a time. Is there some way to cast the array to a type of Zone? Like in Java?
Right now I'm considering changing the array to a cell array. But I'd prefer to keep this as an array of objects of type Zone.
Note: Zone doesn't have to be Abstract.
EDIT
I found a similar question here about specifically abstract classes. So this question might be a duplicate.
How do I create an array of abstract class objects in MATLAB?
 
    