How can I save objects of different classes that inherit all from the same superclass
Mostra commenti meno recenti
Hi,
I currently have the problem, that I have implemented a program, where I save objects in an array. Now I have implemented another type of object that inherits from the same superclass as the other objects (superclass: node, subclasses: node_flow, node_heat) I want to save objects of both classes(node_flow and node_heat) in an array. when I want to create a list as followed: global_node_list(i) with a for loop I get an error that MATLAB is not able to convert from node_heat to node_flow. I know that I can use a cell array, but I do not want to change 50 different m-files. Is there any other possibility to save the objects?
Risposte (1)
per isakson
il 13 Feb 2013
Modificato: per isakson
il 14 Feb 2013
If I understood your question correctly, this excerpt from the help is a starting point:
matlab.mixin.Heterogeneous is an abstract class that provides support for the
formation of heterogeneous arrays. A heterogeneous array is an array of objects
that differ in their specific class, but are all derived from or are instances
of a root class. The root class derives directly from matlab.mixin.Heterogeneous.
Categorie
Scopri di più su Subclass Definition in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!