How to extract cell array in matlab
Mostra commenti meno recenti
Hello.. Anyone does know? I need to extract from cell array (1x1 cell). For example > '22.11.2011 13:58:56.16' from this (1x1 cell).I want to extract time in second (:56) .How can I do. Thanks.
Risposta accettata
Più risposte (3)
Andrei Bobrov
il 21 Nov 2011
out = datevec({'22.11.2011 13:58:56.16'},'dd.mm.yyyy HH:MM:SS')
out = out(end)
OR
out = sprintf(':%d',out(end))
4 Commenti
Sven
il 21 Nov 2011
Oh, 3 answers within minutes. Who will get the "accept" from Mr. Smart. The suspense is killing me!
;-)
Walter Roberson
il 21 Nov 2011
Mine will! None of the rest of you noticed that the ':' was a mandatory part of the output!
Andrei Bobrov
il 22 Nov 2011
@Sven: Walter :)
Mr Smart
il 22 Nov 2011
Walter Roberson
il 21 Nov 2011
> datestr(datenum({'22.11.2011 13:58:56.16'},'dd.mm.yyyy HH:MM:SS.FFF'),':SS')
ans =
:56
>> char(cellfun(@(T) T(end-5:end-3), {'22.11.2011 13:58:56.16'},'Uniform',0))
ans =
:56
2 Commenti
Walter Roberson
il 22 Nov 2011
Based upon the previous answers, the following should also work:
datestr(datevec({'22.11.2011 13:58:56.16'}),':SS')
Mr Smart
il 22 Nov 2011
Categorie
Scopri di più su Licensing on Cloud Platforms 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!