Reading a time column

5 ビュー (過去 30 日間)
Shahar ben ezra
Shahar ben ezra 2021 年 5 月 2 日
コメント済み: Star Strider 2021 年 5 月 2 日
Hello
I have a CSV file, with columns of times
When I read the file by readmatrix or readcell or readtable
I get columns of values ​​rather than times
How can I fix the problem?

採用された回答

Star Strider
Star Strider 2021 年 5 月 2 日
Here is one approach —
Excel_Val = '16:50:13' % Original
Excel_Val = '16:50:13'
MATLAB_Val = rem(datenum(Excel_Val, 'HH:MM:SS'),1) % Fraction-Of-Day Representration
MATLAB_Val = 0.7015
dt = datetime(MATLAB_Val, 'ConvertFrom','datenum', 'Format','HH:mm:ss') % ‘datetime’ Conversion
dt = datetime
16:50:13
.
  2 件のコメント
Shahar ben ezra
Shahar ben ezra 2021 年 5 月 2 日
Thanks!
What is the 1 used for? (iin MATLAB_Val = rem(datenum(Excel_Val, 'HH:MM:SS'),1)
If I have a vector of times does it matter??
Star Strider
Star Strider 2021 年 5 月 2 日
As always, my pleasure!
The 1 in the rem call isolates the decimal fraction part of the floating-point argument to it.
For example —
arg = pi
arg = 3.1416
decfrax_arg = rem(arg,1)
decfrax_arg = 0.1416
.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeText Files についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by