How a read the particular character from a string?

Kindly looking for help on a small question. any help is highly appreciated!!
I got this string in a format e.g. 13:30:00 which essentially display the time. Now I need to seperate 13, 30, 00 into 3 different string. Maybe we can use str2double to convert the string into double first so it will be more easily handled?
Thank you once again.

回答 (1 件)

Sean de Wolski
Sean de Wolski 2012 年 2 月 9 日

0 投票

regexp('13:30:00',':','split') %split on ':'

2 件のコメント

Yu Wang
Yu Wang 2012 年 2 月 9 日
Thank you for your help. But now the problem is how to use these split srings. I can use "clock" function to return the current time which is a 6-element cell, I can simply let c=clock, then use c(4), c(5), c(6) to return hour, mininute, second individually. What I want is compare the hours, mins and seconds, and use a simple formula to calculate the total different in seconds.
Walter Roberson
Walter Roberson 2012 年 2 月 9 日
Possibly easier to convert the string time in to a serial date num, subtract from the clock() result, and multiply the result by 24*60*60 to get the difference in seconds.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeCharacters and Strings についてさらに検索

質問済み:

2012 年 2 月 9 日

編集済み:

2013 年 10 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by