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?
Ältere Kommentare anzeigen
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 Kommentare
Mahdi
am 4 Jun. 2014
You didn't attach a file.
anton fernando
am 4 Jun. 2014
anton fernando
am 4 Jun. 2014
Image Analyst
am 5 Jun. 2014
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.
Akzeptierte Antwort
Weitere Antworten (2)
dpb
am 4 Jun. 2014
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 Kommentare
anton fernando
am 4 Jun. 2014
anton fernando
am 4 Jun. 2014
dpb
am 4 Jun. 2014
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
am 4 Jun. 2014
Bearbeitet: anton fernando
am 4 Jun. 2014
0 Stimmen
Kategorien
Mehr zu Data Import and Export finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!