Static methods not recognized (initially) in R2015a

4 Ansichten (letzte 30 Tage)
Matt J
Matt J am 9 Okt. 2015
Bearbeitet: Jan Siegmund am 4 Mai 2020
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 Kommentare
Matt J
Matt J am 9 Okt. 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 am 4 Mai 2020
Bearbeitet: Jan Siegmund am 4 Mai 2020
Thank you, rehash saved me for a different problem, where a static method was recognized as a variable.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by