Effacer les filtres
Effacer les filtres

Error getting day of year from datetime.

3 vues (au cours des 30 derniers jours)
Adrienne Marshall
Adrienne Marshall le 11 Avr 2016
Hi - I'm trying to extract a day of year from a datetime, and get the error message: "Function 'subsindex' is not defined for values of class 'datetime'."
I get this message even when I copy-paste the code from the documentation for the day function:
t = [datetime('yesterday');datetime('today');datetime('tomorrow')]
d = day(t)
Any ideas or suggestions?

Réponse acceptée

Steven Lord
Steven Lord le 11 Avr 2016
You've probably defined a variable named day in your workspace. MATLAB is trying to use the datetime array as an index into that variable, but MATLAB doesn't know how to do that. [What is x(lastTuesday)?] Remove the variable and the command should work.
  1 commentaire
Adrienne Marshall
Adrienne Marshall le 11 Avr 2016
You're exactly right - thank you!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by