remove end comma
Show older comments
hi,
I have '2005-04-19'
how get 2005-04-19
thanks
Answers (1)
Walter Roberson
on 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 Comments
huda nawaf
on 7 Nov 2011
Walter Roberson
on 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
on 7 Nov 2011
Walter Roberson
on 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');
Categories
Find more on Dates and Time in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!