NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/gliderproc/trunk/MATLAB/util/read_gliderasc.m

Revision 495 (checked in by cbc, 12 years ago)

Initial import of Stark code.

Line 
1
2 function dstruct = read_gliderasc(file)
3
4 % Calls: strfun/blank
5
6 datadir = '';
7 %file='test2.asc';
8
9 fid = fopen(blank([datadir,file]),'r');
10
11 if(fid<0);
12     error(['File ',file,' does not exist.']);
13 end
14
15 for i=1:3 
16   line = fgetl(fid);
17 end
18
19 % grab #
20 nvar = str2num(line(17:end));
21 for i=1:5
22   line = fgetl(fid);
23 end
24
25 dstruct.fname = line(17:end);
26 line = fgetl(fid);
27 dstruct.mname = line(15:end);
28 for i=1:6
29   line = fgetl(fid);
30 end
31
32 %line=fgetl(fid);
33 line2 = fgetl(fid);
34 ndigits = str2num(fgetl(fid));
35 blpos = [0 find(line==' ') length(line)-1];
36 blpos2 = [0 find(line2==' ') length(line2)-1];
37 for i=1:length(blpos)-2
38   dstruct.vars{i} = line(blpos(i)+1:blpos(i+1));
39   dstruct.varlabs{i} = line2(blpos2(i)+1:blpos2(i+1));
40 end
41
42 data=[];
43 while 1
44   line=fgetl(fid);
45   if ischar(line);
46       data=[data;
47       str2num(line)];
48   else;
49       break;
50   end
51 end
52 fclose(fid);
53 dstruct.data = data;
54 %d=fscanf(fid,'%f %f %f %f %f %f %f %f %f %f %f %f %f %f\n',[14 inf]);
Note: See TracBrowser for help on using the browser.