Azzera filtri
Azzera filtri

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

11 visualizzazioni (ultimi 30 giorni)
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 Commenti
lyra
lyra il 12 Ago 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 il 12 Ago 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...

Accedi per commentare.

Risposte (1)

Prahlad Gowtham Katte
Prahlad Gowtham Katte il 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

Categorie

Scopri di più su Class Introspection and Metadata in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by