I want to read the header data. The data file is attached. In the fffffff row there are two data values that I need to read and also in the qqqqqq column there is only one data. How can i read this?
이전 댓글 표시
The data file is attached. In the fffffff row there are two data values that I need to read and also in the qqqqqq column there is only one data. How can i read this? Please see the attached file.
댓글 수: 4
Mahdi
2014년 6월 4일
You didn't attach a file.
anton fernando
2014년 6월 4일
anton fernando
2014년 6월 4일
Image Analyst
2014년 6월 5일
You still didn't attach it. You attached a screenshot of it displayed in your screen. We need to see something with a .nc extension, not .jpg or other image format.
채택된 답변
추가 답변 (2개)
dpb
2014년 6월 4일
fid=fopen('yourfile','r');
fgetl(fid)
l=fgetl(fid);
datedata=sscanf(l(strfind(l,'|')+1:end),'%4d-2d-2d %2d:%2d:%2d+%2d');
fgetl(fid)
l=fgetl(fid);
data=sscanf(l(strfind(l,'|')+1:end),'%f');
Will have y,m,d,h,mn,s,tzoffset in datedata array and the floating pt value in data
Can do w/ textscan and 'headerline' but the fgetl call serves the purpose here.
댓글 수: 3
anton fernando
2014년 6월 4일
anton fernando
2014년 6월 4일
dpb
2014년 6월 4일
There is no column qqqqq?
The returned values for the header row are numeric; datedata are integer-valued while data isn't but they're all default doubles in Matlab.
If the question is to then read the tabular data, just skip a couple more lines and then since there's no formatting or skiping any text or the like, just a regular array, fscanf can return the full array in one swell foop.
As for what happens, read it from inside out after executing the first few lines at the command window to get a line into variable l. Look up strfind if you can't decipher what it's doing just from the name and arguments and
doc colon
doc end
for the addressing. The format strings are all described in the doc for fscanf and friends...there's no replacement for simply learning syntax and functionality in Matlab by reading the documentation and experimenting on the command line to see how something works.
anton fernando
2014년 6월 4일
편집: anton fernando
2014년 6월 4일
0 개 추천
카테고리
도움말 센터 및 File Exchange에서 Data Import and Export에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!