フィルターのクリア

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

11 ビュー (過去 30 日間)
lyra
lyra 2021 年 8 月 11 日
回答済み: Prahlad Gowtham Katte 2022 年 2 月 15 日
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 件のコメント
lyra
lyra 2021 年 8 月 12 日
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 2021 年 8 月 12 日
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...

サインインしてコメントする。

回答 (1 件)

Prahlad Gowtham Katte
Prahlad Gowtham Katte 2022 年 2 月 15 日
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

カテゴリ

Help Center および File ExchangeClass Introspection and Metadata についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by