Backward compatibility of matlab.mixin.SampleTime class

1 view (last 30 days)
I am using matlab.mixin.SampleTime in various own developed Matlab System classes. Now with R2021b release matlab.mixin.SampleTime was moved to matlab.System classes. As a consequence one has to remove the matlab.mixin.SampleTime inheritence in all class definitions where it hast been used :-(. Even worse for me, I want to keep using my existing code with older Matlab versions. Can you propose any solution?

Answers (1)

Pratyush
Pratyush on 16 Jan 2024
Hi Andre,
I understand that you want to maintain a single codebase that is compatible with multiple MATLAB versions.
To maintain compatibility with both the older versions of MATLAB and the R2021b (and later) releases, one approach is to conditionally inherit from matlab.mixin.SampleTime based on the MATLAB version at the time of execution. You can use MATLAB's "isMATLABReleaseOlderThan" function to determine the version and then dynamically inherit from the correct superclass. You can refer to this documentation for more details: https://in.mathworks.com/help/matlab/ref/ismatlabreleaseolderthan.html

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!