|
1 % Usage: D = loadANTS(filename[,fieldname[,...]]); |
|
2 % |
|
3 % Examples: |
|
4 % prof = loadANTS('070.2db'); |
|
5 % - read all fields from file 070.2db into matrix prof |
|
6 % - each field becomes a column |
|
7 % prof = loadANTS('070.2db','press','temp','salin'); |
|
8 % - read pressure, temperature, and salinity fields from file 070.2db |
|
9 % into matrix prof |
|
10 % - 1st column is pressure, 2nd column is temperature, 3rd column is |
|
11 % salinity |
|
12 |
|
13 %====================================================================== |
|
14 % L O A D A N T S . M |
|
15 % doc: Fri Sep 17 11:12:44 2010 |
|
16 % dlm: Fri Sep 17 11:41:01 2010 |
|
17 % (c) 2010 A.M. Thurnherr |
|
18 % uE-Info: 25 29 NIL 0 0 72 2 2 4 NIL ofnI |
|
19 %====================================================================== |
|
20 |
|
21 function D = loadANTS(file,varargin) |
|
22 |
|
23 if nargin==1 |
|
24 cmd = sprintf('data -Qw %s',file); |
|
25 [status,dta] = system(cmd); |
|
26 if status~=0 |
|
27 error(sprintf('cmd "%s" failed',cmd)); |
|
28 end |
|
29 nfields = sscanf(dta,'%d'); |
|
30 cmd = sprintf('Cat -Q %s',file); |
|
31 else |
|
32 nfields = nargin-1; |
|
33 cmd = 'list -Q'; |
|
34 for i=1:nfields |
|
35 cmd = sprintf('%s %s',cmd,varargin{i}); |
|
36 end |
|
37 cmd = sprintf('%s %s',cmd,file); |
|
38 end |
|
39 |
|
40 [status,dta] = system(cmd); |
|
41 if status~=0 |
|
42 error(sprintf('cmd "%s" failed',cmd)); |
|
43 end |
|
44 |
|
45 D = sscanf(dta,'%f',[nfields,inf])'; |
|
46 |