Static methods not recognized (initially) in R2015a

4 views (last 30 days)
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 Comments
Matt J
Matt J on 9 Oct 2015
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 on 4 May 2020
Edited: Jan Siegmund on 4 May 2020
Thank you, rehash saved me for a different problem, where a static method was recognized as a variable.

Sign in to comment.

Answers (0)

Categories

Find more on MATLAB 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!