- Timestamp:
- Mar 19, 2010, 9:56:38 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/struct2nc_toolbox.m
r46 r58 111 111 nc{ListVarName{ivar}}(:) = VarVal; 112 112 end 113 %write variable attributes114 if testattr 115 for ivarattr=1:length(VarAttribute) 116 if isstruct(VarAttribute{ivarattr}) 117 attr_names=fields(VarAttribute{ivarattr});118 for iattr=1:length(attr_names)119 eval(['attr_val=VarAttribute{ivar}.' attr_names{iattr} ';']);120 if ischar(attr_val) && ~isequal(attr_val,'')121 eval(['nc{''' ListVarName{ivar} '''}.' attr_names{iattr} '=''' attr_val ''';'])122 elseif isnumeric(attr_val)&& ~isempty(attr_val)123 eval(['nc{''' ListVarName{ivar} '''}.' attr_names{iattr} '=attr_val;'])124 end125 end113 end 114 end 115 %write variable attributes 116 if testattr 117 for ivar=1:length(VarAttribute) %loop on the attributes of variable ivar 118 if isstruct(VarAttribute{ivar}) 119 attr_names=fields(VarAttribute{ivar}); 120 for iattr=1:length(attr_names) 121 eval(['attr_val=VarAttribute{ivar}.' attr_names{iattr} ';']); 122 if ischar(attr_val) && ~isequal(attr_val,'') 123 eval(['nc{''' ListVarName{ivar} '''}.' attr_names{iattr} '=''' attr_val ''';']) 124 elseif isnumeric(attr_val)&& ~isempty(attr_val) 125 eval(['nc{''' ListVarName{ivar} '''}.' attr_names{iattr} '=attr_val ;']) 126 126 end 127 127 end 128 128 end 129 129 end 130 end 130 end 131 131 132 132 133 close(nc);
Note: See TracChangeset
for help on using the changeset viewer.