Filter löschen
Filter löschen

convert string to number

3 Ansichten (letzte 30 Tage)
Mate 2u
Mate 2u am 21 Feb. 2012
Bearbeitet: Cedric am 19 Okt. 2013
Hi I have a string array as following:
'15:30:00'
'15:30:01'
'15:30:02'
'15:30:03'
'15:30:04'
'15:30:05'
'15:30:06'
ETC.....
I want the out put to be like 153000
153001
153002
153003
etc,
any help

Akzeptierte Antwort

Jan
Jan am 21 Feb. 2012
S = {'15:30:00'; '15:30:01'; '15:30:02'};
S = strrep(S, ':', '');
D = sscanf(sprintf('%s ', S{:}), '%d');
  1 Kommentar
Andrei Bobrov
Andrei Bobrov am 21 Feb. 2012
D = str2num(datestr(S,'HHMMSS'))

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Sean de Wolski
Sean de Wolski am 21 Feb. 2012
s = '15:30:00';
sn = str2double(s(isstrprop(s,'digit')))

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by