remove end comma
显示 更早的评论
回答(1 个)
Walter Roberson
2011-11-7
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 个评论
huda nawaf
2011-11-7
Walter Roberson
2011-11-7
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
2011-11-7
Walter Roberson
2011-11-7
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');
类别
在 帮助中心 和 File Exchange 中查找有关 Dates and Time 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!