Static methods not recognized (initially) in R2015a

5 visualizaciones (últimos 30 días)
Matt J
Matt J el 9 de Oct. de 2015
Editada: Jan Siegmund el 4 de Mayo de 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 comentarios
Matt J
Matt J el 9 de Oct. de 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 el 4 de Mayo de 2020
Editada: Jan Siegmund el 4 de Mayo de 2020
Thank you, rehash saved me for a different problem, where a static method was recognized as a variable.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by