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

4 visualizaciones (últimos 30 días)
lyra
lyra el 11 de Ag. de 2021
Respondida: Prahlad Gowtham Katte el 15 de Feb. de 2022
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 comentarios
lyra
lyra el 12 de Ag. de 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 el 12 de Ag. de 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...

Iniciar sesión para comentar.

Respuestas (1)

Prahlad Gowtham Katte
Prahlad Gowtham Katte el 15 de Feb. de 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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by