"week.m" file disapeared
Mostrar comentarios más antiguos
I successfully used the built-in function "week.m" last week but it seems that the matlab file has now disapeared. When I try to use it (e.g. week(1)) I get the following error message: Undefined function 'week' for input arguments of type 'double'. I checked in the finance/calendar, all is there but not the week.m file nor the quarter.m..... Any idea how to recover it ?
3 comentarios
Matt J
el 14 de Jul. de 2015
I've never used week(), but mysteriously, on my machine, the doc command can find it
>>doc week
but not help, which, or anything else. Weird...
Arnaud Melin
el 14 de Jul. de 2015
Brendan Hamm
el 14 de Jul. de 2015
This has to do with how classes are defined. If the class is not loaded into memory, then one cannot access its methods (it's as if they are not on the path). But you can access the documentation as the doc is not searching the MATLAB path for a file of the given name like help and which do.
Respuesta aceptada
Más respuestas (1)
Titus Edelhofer
el 14 de Jul. de 2015
Editada: Titus Edelhofer
el 14 de Jul. de 2015
1 voto
Hi,
EDIT: my answer below is not correct, but the comment explains what's going on.
Hmm, are you sure this is a MathWorks supplied file? I know of weekday (MATLAB) and weeknum (Financial Toolbox) but not of week ...?
Maybe you copied it from somewhere? And maybe it's just a path thing, i.e., the folder containing your week.m is not on the MATLAB search path.
Try to locate week.m on your disk and use pathtool to add the folder in MATLAB.
Titus
2 comentarios
Titus Edelhofer
el 14 de Jul. de 2015
Sorry, I stumbled across this myself and now (with the help of the others) remember. As long as you haven't created any datetime object, the class definition is not loaded and therefore which doesn't find it. This works:
t = datetime
t =
14-Jul-2015 16:59:24
which week
C:\MATLAB\R2015a\toolbox\matlab\timefun\@datetime\datetime.m % datetime method
Brendan Hamm
el 14 de Jul. de 2015
Correct, which would require the class definition is loaded, but the doc command would not have this requirement.
Categorías
Más información sobre Dates and Time en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!