- Use a subclass so that you do not have to change the installation directory.
- Define new post-processing functions in your current working directory that you could use directly. While you could match the names to the built-in functions, it would be wise to name them differently to ensure that you do not observe a number of shadowing errors.
- Alternatively, you could always store your Simulink outputs in another form, e.g. as an array.
how to overload methods for timeseries ?
1 view (last 30 days)
Show older comments
Luc on 31 Jan 2017
Answered: Hannes Daepp on 14 Feb 2017
How to overload methods for timeseries ? I want to add some methods for timerseries objects, eg atan2(TS1,TS2), power(TS,a), sqrt(TS). The global target is to ease postprocessing of logging data from simulink (with a more 'fluid' code).
I tried to define a directory \@timeseries (in my work directory), containing the dedicated functions.
When I type >>help power, the help includes the mention 'Overloaded methods:timeseries/power'.
Nevertheless, power(TSobj,2) always rethrow the error 'Undefined function 'power' for input arguments of type 'timeseries'.
Hannes Daepp on 14 Feb 2017
For methods defined in separate files, the constructor still needs to be in the directory , which effectively means that you have to define the methods in the installation directory. You can find that using the following command:
>> which -all timeseries
The first result is likely the constructor, which is located in the @timeseries folder.
For example, if you create a "power" function in this directory (you may need to copy it in outside MATLAB to ensure write access), you can then use the following commands to update MATLAB:
>> rehash toolboxcache
>> clear classes
While this will work, I wouldn't necessarily recommend it. There are a few other options you might consider:
Find more on Environment and Settings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!