Changeset 906 for trunk/src/sub_field.m
- Timestamp:
- May 31, 2015, 7:49:31 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sub_field.m
r876 r906 98 98 %% field request 99 99 ProjModeRequest=cell(size(Field.ListVarName)); 100 if isfield(Field,'VarAttribute') 100 101 for ilist=1:numel(Field.VarAttribute) 101 102 if isfield(Field.VarAttribute{ilist},'ProjModeRequest') … … 103 104 end 104 105 end 106 end 105 107 ProjModeRequest_1=cell(size(Field_1.ListVarName)); 108 if isfield(Field_1,'VarAttribute') 106 109 for ilist=1:numel(Field_1.VarAttribute) 107 110 if isfield(Field_1.VarAttribute{ilist},'ProjModeRequest') … … 109 112 end 110 113 end 111 114 end 112 115 113 116 %% rename the dimensions of the second field if identical to those of the first … … 162 165 check_rename=zeros(size(ListVarNameSub)); 163 166 check_remove=zeros(size(ListVarNameSub)); 164 for ilist=1:numel(ListVarNameSub) 165 ind_prev=find(strcmp(ListVarNameSub{ilist},Field.ListVarName),1);% look for duplicated variable name 166 if ~isempty(ind_prev)% variable name exists in Field 167 if isfield(Field_1.VarAttribute{ilist},'Role')&&... 168 ismember(Field_1.VarAttribute{ilist}.Role,{'coord_x','coord_y','scalar','vector_x','vector_y','errorflag'}) 169 ListVarNameNew{ilist}=[ListVarNameSub{ilist} '_1'];%modify the name of the second variable 170 check_rename(ilist)=1; 171 else 172 check_remove(ilist)=1;% variable will be removed 173 end 174 end 175 end 176 ListVarNameSub=ListVarNameSub(~check_remove); %eliminate removed variables from the list of the second field 177 ListVarNameNew=ListVarNameNew(~check_remove); % %list of renaimed varaibles corresponding to ListVarNameSub 178 VarDimNameSub=Field_1.VarDimName(~check_remove); 179 if numel(Field_1.VarAttribute)<max(find(~check_remove)) 180 for ilist=numel(Field_1.VarAttribute)+1:max(find(~check_remove)) 181 Field_1.VarAttribute{ilist}={}; 182 end 183 end 184 VarAttributeSub=Field_1.VarAttribute(~check_remove); 185 check_rename=check_rename(~check_remove); 186 167 VarDimNameSub={}; 168 VarAttributeSub={}; 169 if isfield(Field_1,'VarAttribute')&&~isempty(Field_1.VarAttribute) 170 for ilist=1:numel(ListVarNameSub) 171 ind_prev=find(strcmp(ListVarNameSub{ilist},Field.ListVarName),1);% look for duplicated variable name 172 if ~isempty(ind_prev)% variable name exists in Field 173 if isfield(Field_1.VarAttribute{ilist},'Role')&&... 174 ismember(Field_1.VarAttribute{ilist}.Role,{'coord_x','coord_y','scalar','vector_x','vector_y','errorflag'}) 175 ListVarNameNew{ilist}=[ListVarNameSub{ilist} '_1'];%modify the name of the second variable 176 check_rename(ilist)=1; 177 else 178 check_remove(ilist)=1;% variable will be removed 179 end 180 end 181 end 182 ListVarNameSub=ListVarNameSub(~check_remove); %eliminate removed variables from the list of the second field 183 ListVarNameNew=ListVarNameNew(~check_remove); % %list of renaimed varaibles corresponding to ListVarNameSub 184 VarDimNameSub=Field_1.VarDimName(~check_remove); 185 if numel(Field_1.VarAttribute)<max(find(~check_remove)) 186 for ilist=numel(Field_1.VarAttribute)+1:max(find(~check_remove)) 187 Field_1.VarAttribute{ilist}={}; 188 end 189 end 190 VarAttributeSub=Field_1.VarAttribute(~check_remove); 191 check_rename=check_rename(~check_remove); 192 end 187 193 % apply the variable renaming and mark the second field variables with the attribute .CheckSub 188 194 for ilist=1:numel(ListVarNameSub)
Note: See TracChangeset
for help on using the changeset viewer.