remove end comma
Mostra commenti meno recenti
hi,
I have '2005-04-19'
how get 2005-04-19
thanks
Risposte (1)
Walter Roberson
il 7 Nov 2011
Do you really have the apostrophes there, or are you just seeing the way that MATLAB displays a string that is stored in a cell array?
If the apostrophes are really there, then
B = A(2:end-1);
4 Commenti
huda nawaf
il 7 Nov 2011
Walter Roberson
il 7 Nov 2011
You should consider using 'CollectOutput', 1 as a textscan() parameter.
When you have a %s parameter, because the length of each string might be different, each string is returned in its own cell array element. c(3) is a cell array of cell arrays, and c{3} is a cell array, making your c3 a cell array. c3(g) is then a 1x1 cell array, so your c4 is a 1x1 cell array. And that's why it displays with the apostrophes, exactly as I foretold at the beginning of my answer.
You want c4 = c3{g}
and then do not bother removing anything from that string. Just pass c4 to datenum as the first parameter:
c33(g) = datenum(c4, 'dd-mmm-yyyy');
Or you could just omit the entire loop over g, using instead
c33 = datenum(c{3}, 'dd-mmm-yyyy');
huda nawaf
il 7 Nov 2011
Walter Roberson
il 7 Nov 2011
Ah, you changed in and out of date formats for no apparent reason.
This should do the conversion in one step:
c33 = datenum(c{3}, 'yyyy-mm-dd');
Categorie
Scopri di più su Dates and Time in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!