Filter löschen
Filter löschen

Is it possible to write a class that inherits from timetable?

4 Ansichten (letzte 30 Tage)
lyra
lyra am 11 Aug. 2021
Hi. I would like to write a class that inherits from the timetable class, so that I can write my own methods (e.g. for manipulating and graphing time-series data). Is there any way to do this? Attempting to do so using:
classdef mySubClass < timetable
gives the error:
Class 'timetable' is Sealed and may not be used as a superclass.
Specifically, I'm not seeking to modify the base timetable class. I simply want to inherit from it and extend it with some specific attributes/methods.
  3 Kommentare
lyra
lyra am 12 Aug. 2021
Thanks, yes - this is a possible workaround. Matlab's timeseries object is also built on timetable and can be inherited from. However, both of these solutions involve an extra layer of nesting (which is superfluous for my use-case). As this object will be a foundational data structure for what could end-up being a very large toolbox, I'd much rather avoid if I can. Will continue to search (and hope) for a solution for now.
J. Alex Lee
J. Alex Lee am 12 Aug. 2021
If you go the route suggested by @Jeff Miller and want to be able to directly access the timetable properties from your "wrapper" without having to reference the property containing the timetable itself, you could also inherit from dynamicproperties and kind of "automatically" expose the timetable properties by duplicating them as dynamic properties in your "wrapper" class, and then write a generic setter/getter for them.
not perfect, but it's one way...

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Prahlad Gowtham Katte
Prahlad Gowtham Katte am 15 Feb. 2022
Hello,
As per my understanding of the query, you are trying to inherit a sealed class which is not possible. For your case though as suggested in the comments you can use a timetable as a property and add methods on that.
The following link is attached as reference to non-inheritance property of sealed class
Hope it helps

Kategorien

Mehr zu Class Introspection and Metadata finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by