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!