- 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 回表示 (過去 30 日間)
古いコメントを表示
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'.
0 件のコメント
回答 (1 件)
Hannes Daepp
2017 年 2 月 14 日
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:
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Search Path についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!