problem with if cycle to determine the datetime
1 visualizzazione (ultimi 30 giorni)
hi, i'm using a function to retrieve weather data with API. I divided the function in two section, one where the outputs is the current weather and one for "past" weather. To decide which output the function has to print I made a simpole if cycle:
if fullDate == now
... %outputs current weather
... %outputs historic weather
if I try to run the single part everything works perfecty, but adding this if cylce I get this error message using fullDate = now;
Numeric input data must be a matrix with three or six columns, or else three, six, or seven separate numeric arrays. You can also create datetimes from a single numeric array using the 'ConvertFrom' parameter.
the wierd thing is that if I continue to run the code (without touching it) after a few errors sometimes it runs without any problem.
I don't get where is the problem... thanks
Les Beckham il 3 Feb 2023
Modificato: Les Beckham il 3 Feb 2023
The time returned by datetime('now') will be changing as your code runs, so it seems almost impossible that your if condition will ever be met. Perhaps you should apply a tolerance or use a different condition.
t1 = datetime('now'),t2 = datetime('now')