Reading in a text file with date and time

조회 수: 4 (최근 30일)
John
John 2014년 4월 16일
편집: dpb 2014년 4월 18일
I have a text file (e.g. discharge.txt) that I wish to read in in the following format:
Date Discharge (m3/s)
09/04/2014 10:15 9.587*
09/04/2014 10:30 9.497*
09/04/2014 10:45 9.363*
09/04/2014 11:00 9.231*
09/04/2014 11:15 9.143*
I would ideally wish to obtain 6 vectors.
  • A vector showing the integer value for month
  • A vector showing the integer value for year
  • A vector showing the integer value for day
  • A vector showing the integer value for hour
  • A vector showing the integer value for minute
  • A vector showing the value for discharge (no asterisk)
Thanks!

답변 (1개)

dpb
dpb 2014년 4월 17일
편집: dpb 2014년 4월 18일
[m,d,y,h,mn,disch]=textread('discharge.dat','%d/%d/%d %f*');
doc textread
doc textscan
doc fscanf
help iofun
Read "Getting Started"

카테고리

Help CenterFile Exchange에서 Text Files에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by