problem in reading datetime

조회 수: 2 (최근 30일)
lina
lina 2015년 6월 21일
답변: dpb 2015년 6월 21일
HI ALL
I Got a problem in reading string data file, the error is
??? Error using ==> textscan Invalid file identifier. Use fopen to generate a valid file identifier.
and the command which I used is
fid=fopen('ARBY STARL 170310-200514 LT Edited_OBS TIDES 6mins.dat','r','n','ARAB');
s=textscan(fid,'%{dd MMMM yyyy hh:mm}D %f %f','DateLocale','Delimiter',',');
fclose(ARBY STARL 170310-200514 LT Edited_OBS TIDES 6mins);
finally, my data type is
31 May 2012 04:20,02.650
31 May 2012 04:25,02.640
31 May 2012 04:30,02.630
31 May 2012 04:35,02.630
anyone can help?

답변 (1개)

dpb
dpb 2015년 6월 21일
The file wasn't opened successfully as the error says...use the alternate return to find out additional information on why...
[fid,msg]=fopen('ARBY STARL 170310-200514 LT Edited_OBS TIDES 6mins.dat','r','n','ARAB')
and see what the error message is for hints. I note the character code is not in the listed options so while Matlab will not error it will warn and may or may not provide a correct interpretation. I'd suggest unless there's a known reason, simply use the defaults other than for file permission although the most likely cause for fopen to fail is that the file is not located on the path and so simply isn't found. But, I'd still suggest
[fid,msg]=fopen('ARBY STARL 170310-200514 LT Edited_OBS TIDES 6mins.dat','rt')
as first go and check the returned handle is valid before going on to try to read anything 'cuz "it ain't agonna' work" until it is (valid that is).

카테고리

Help CenterFile Exchange에서 Oceanography and Hydrology에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by