フィルターのクリア

How to convert minutes, seconds, milliseconds to seconds?

10 ビュー (過去 30 日間)
Navikesh Krishna
Navikesh Krishna 2019 年 9 月 23 日
編集済み: Cris LaPierre 2019 年 9 月 23 日
hey,
How can I return an array with
min:sec:milli-seconds
into
seconds?
For example

採用された回答

Cris LaPierre
Cris LaPierre 2019 年 9 月 23 日
編集済み: Cris LaPierre 2019 年 9 月 23 日
You don't sepcify your file type. I'm going to assume a csv though this only matters for getting the data into MATLAB. My goal is to import it as a string. Modify as necessary for your file.
opts = detectImportOptions("timeData.csv","ReadVariableNames",false);
opts = setvartype(opts,1,"string");
data = readtable("timeData.csv",opts);
Once the data is read in as a table, convert it to a duration so that the time has units. As part of this, you can specify the input format.
tm = duration({data.Var1{:}},"InputFormat","mm:ss.SSSS")
You can view the seconds in two ways.
1. Use the seconds function
seconds(tm)
2. Specify the output format when converting to a duration.
tm = duration({data.Var1{:}},"InputFormat","mm:ss.SSSS",'Format',"s")

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by