Static methods not recognized (initially) in R2015a

4 ビュー (過去 30 日間)
Matt J
Matt J 2015 年 10 月 9 日
編集済み: Jan Siegmund 2020 年 5 月 4 日
Below is a copy/paste of a sequence of commands that I executed at the command line in R2015a and its output. Here GeoCalCho and TrajClass are both value classes that I have defined and GeoCalCho.split() is a static method of the GeoCalCho class. It is supposed to take a TrajClass object, th, as input and return two TrajClass objects, thu and thl, as output.
>> clear GeoCalCho
>> [thu,thl]=GeoCalCho.split(th)
Undefined variable "GeoCalCho" or class "GeoCalCho.split".
>> GeoCalCho %call class constructor
Error using GeoCalCho (line 31)
Not enough input arguments.
>> [thu,thl]=GeoCalCho.split(th)
thu =
TrajClass with properties:
data: [2x8x558 double]
coordsys: 'ij'
thl =
TrajClass with properties:
data: [2x8x558 double]
coordsys: 'ij'
So why doesn't MATLAB recognize GeoCalCho as a static method, initially? Clearly it is not a path problem. When I called the GeoCalCho class constructor, MATLAB finds it successfully. Moreover, MATLAB is thereafter able to find GeoCalCho.split(), although I haven't done anything to the path.
This is just an example. I have seen the same kind of behavior with other classes, though regrettably, I haven't found a way to reproduce it reliably. Has anyone else noticed this?
  2 件のコメント
Matt J
Matt J 2015 年 10 月 9 日
I find that REHASH also works as a way of making MATLAB aware of the static method, but I don't see why that would be necessary
>> clear GeoCalCho
>> [thu,thl]=GeoCalCho.split(th)
Undefined variable "GeoCalCho" or class "GeoCalCho.split".
>> rehash
>> [thu,thl]=GeoCalCho.split(th)
thu =
TrajClass with properties:
data: [2x8x558 double]
coordsys: 'ij'
thl =
TrajClass with properties:
data: [2x8x558 double]
coordsys: 'ij'
Jan Siegmund
Jan Siegmund 2020 年 5 月 4 日
編集済み: Jan Siegmund 2020 年 5 月 4 日
Thank you, rehash saved me for a different problem, where a static method was recognized as a variable.

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by