18
|
1 |
% function [] = add_struct(ncf,snm,a)
|
|
2 |
%
|
|
3 |
% function to add mat structures to attributes field of NetCDF file
|
|
4 |
% called from ladcp2cdf LDEO software to Process LADCP
|
|
5 |
%
|
|
6 |
% input : ncf - output filename
|
|
7 |
% snm - slash indicates a global variable
|
|
8 |
% a - arbitrary metadata structures
|
|
9 |
|
|
10 |
function [] = add_struct(ncf,snm,a)
|
|
11 |
fnames = fieldnames(a);
|
|
12 |
if isstruct(a)
|
|
13 |
for n = 1:size(fnames,1)
|
|
14 |
dummy = getfield(a,fnames{n});
|
|
15 |
if size(dummy,1)==1
|
|
16 |
if isstr(dummy)
|
|
17 |
ncwriteatt(ncf,snm,fnames{n},dummy);
|
|
18 |
elseif islogical(dummy)
|
|
19 |
if dummy, dummy='true';
|
|
20 |
else, dummy='false';
|
|
21 |
end
|
|
22 |
ncwriteatt(ncf,snm,fnames{n},dummy);
|
|
23 |
else
|
|
24 |
ncwriteatt(ncf,snm,fnames{n},dummy(:));
|
|
25 |
end
|
|
26 |
end
|
|
27 |
end % for n
|
|
28 |
else % if issstruct(a)
|
|
29 |
disp(' not structure')
|
|
30 |
end
|
|
31 |
end % function
|
|
32 |
|