Changeset 405 for trunk/src/sub_field.m
- Timestamp:
- May 1, 2012, 10:08:36 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sub_field.m
r402 r405 17 17 18 18 function [SubData,errormsg]=sub_field(Field,Field_1) 19 20 %% global attributes 19 21 test_attr=0; 20 22 if isfield(Field,'ListGlobalAttribute') … … 22 24 for ilist=1:numel(Field.ListGlobalAttribute) 23 25 AttrName=Field.ListGlobalAttribute{ilist}; 24 eval(['SubData.' AttrName '=Field.' AttrName ';'])26 SubData.(AttrName)=Field.(AttrName); 25 27 end 26 28 test_attr=1; … … 49 51 end 50 52 end 53 54 %% variables 51 55 SubData.ListVarName=Field.ListVarName; 52 56 SubData.VarDimName=Field.VarDimName; … … 54 58 SubData.VarAttribute=Field.VarAttribute; 55 59 end 56 %reproduce Field by default60 %reproduce the first field Field by default 57 61 for ivar=1:numel(Field.ListVarName) 58 62 VarName=Field.ListVarName{ivar}; 59 eval(['SubData.' VarName '=Field.' VarName ';'])60 end 61 62 % fields63 SubData.(VarName)=Field.(VarName); 64 end 65 66 %% check the two input fields 63 67 [CellVarIndex,NbDim,VarTypeCell,errormsg]=find_field_indices(Field); 64 68 if ~isempty(errormsg) … … 111 115 end 112 116 113 % substract two vector fields or two scalars117 %% substract two vector fields or two scalars 114 118 if (testU && testU_1) || (~testU && ~testU_1) 115 119 %check coincidence in positions … … 118 122 XName=Field.ListVarName{VarType.coord_x}; 119 123 YName=Field.ListVarName{VarType.coord_y}; 120 eval(['vec_X=Field.' XName ';'])121 eval(['vec_Y=Field.' YName ';'])124 vec_X=Field.(XName); 125 vec_Y=Field.(YName); 122 126 nbpoints=numel(vec_X); 123 127 vec_X=reshape(vec_X,nbpoints,1); … … 361 365 VName_1_1=[VName_1 '_1']; 362 366 end 363 end 367 end 368 364 369 if ~testX_1 365 370 DimCell=[{XName_1_1} {YName_1_1}]; … … 376 381 SubData.VarAttribute=[SubData.VarAttribute {XAttr} {YAttr} {UAttr} {VAttr}]; 377 382 end 378 eval(['SubData.' XName_1_1 '=Field_1.' XName_1 ';'])379 eval(['SubData.' YName_1_1 '=Field_1.' YName_1 ';'])380 eval(['SubData.' UName_1_1 '=Field_1.' UName_1 ';'])381 eval(['SubData.' VName_1_1 '=Field_1.' VName_1 ';'])383 SubData.(XName_1_1)=Field_1.(XName_1); 384 SubData.(YName_1_1)=Field_1.(YName_1); 385 SubData.(UName_1_1)=Field_1.(UName_1); 386 SubData.(VName_1_1)=Field_1.(VName_1); 382 387 end 383 388
Note: See TracChangeset
for help on using the changeset viewer.