Azzera filtri
Azzera filtri

Problem with 'datevec' function ... I think a bug!

1 visualizzazione (ultimi 30 giorni)
First I should denote my Matlab version is R2011a. It's simple: running the simple code below
ans = datevec(input,'dd/mm/yyyy');
input is a cell array. there is no problem when its size is small but when it gets large (42600 in my case), this error is returned:
"??? Error using ==> dtstr2dtvecmx Failed on converting date string to date number.
Error in ==> datevec at 121 ans = datevec(input,'dd/mm/yyyy'); "
how can I deal with that? the function has no problem with a size around 1120 !!

Risposta accettata

Titus Edelhofer
Titus Edelhofer il 25 Lug 2012
Hi,
this usually happens when somewhere down the array the strings are not valid anymore. A simple way to find out:
% assume inputArray to be your string array:
for i=1:length(inputArray)
fprintf('Convert entry %d', i);
t = datevec(inputArray{i});
end
Probably it will fail somewhere, but now you know which is the offending entry.
Titus
PS: BTW I would suggest another name than input, because input is a MATLAB function ...
  1 Commento
Mohammad Monfared
Mohammad Monfared il 25 Lug 2012
yessss U are right... my misunderstanding of input data structure :D
thanks a lot,

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by