read mix data from .txt file

1 回表示 (過去 30 日間)
Jonathan Roy
Jonathan Roy 2011 年 11 月 1 日
I get my data from a txt file like this:
Date Flow
1950-01-01 38.745
1950-01-02 40.243
1950-01-03 40.343
1950-01-04 40.643
How can i get date on a matrix with a column for year, month and day. One other matrix for the flow. I dont need header.
Thank you for your help

採用された回答

Fangjun Jiang
Fangjun Jiang 2011 年 11 月 1 日
Assume your file is called test.txt
>> [Dat,Num]=textread('test.txt','%s %f','headerlines',1)
Dat =
'1950-01-01'
'1950-01-02'
'1950-01-03'
'1950-01-04'
Num =
38.744999999999997
40.243000000000002
40.343000000000004
40.643000000000001
>> [Year,Month,Day]=datevec(Dat)
Year =
1950
1950
1950
1950
Month =
1
1
1
1
Day =
1
2
3
4

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by