This answer states
I don't think you (or I) can do dynamic data structures 'in' MATLAB. We have to use MATLAB OO features and MATLAB classes. Since I think that these facilities are really a MATLAB wrapper around Java I make the bold claim that those facilities are outside MATLAB. A matter of semantics, I concede. If you want to do dynamic data structures with MATLAB, you have to use OO and classes, you can't do it with what I think of as the core language, which lacks pointers at the user level.
Now suppose a bag. New numbers are added to the bag in random order and still the numbers should be ordered. The amount of numbers is unknown. Hence I need a dynamic data-structure: the size of the structure must be able to get changed. Also the structure must be able to get balanced i.e. I need to get it ordered.
Which data structure should I use for the dynamic balanced data-structure requirement in Matlab?