Changeset 405 for trunk/src/sub_field.m


Ignore:
Timestamp:
May 1, 2012, 10:08:36 PM (12 years ago)
Author:
sommeria
Message:

many bugs corrected: composition of 2 input fields, arrow colors from different scalar fields...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sub_field.m

    r402 r405  
    1717
    1818function [SubData,errormsg]=sub_field(Field,Field_1)
     19
     20%% global attributes
    1921test_attr=0;
    2022if isfield(Field,'ListGlobalAttribute')
     
    2224    for ilist=1:numel(Field.ListGlobalAttribute)
    2325        AttrName=Field.ListGlobalAttribute{ilist};
    24         eval(['SubData.' AttrName '=Field.' AttrName ';'])
     26        SubData.(AttrName)=Field.(AttrName);
    2527    end
    2628    test_attr=1;
     
    4951    end
    5052end
     53
     54%% variables
    5155SubData.ListVarName=Field.ListVarName;
    5256SubData.VarDimName=Field.VarDimName;
     
    5458    SubData.VarAttribute=Field.VarAttribute;
    5559end
    56 %reproduce Field by default
     60%reproduce the first field Field by default
    5761for ivar=1:numel(Field.ListVarName)
    5862   VarName=Field.ListVarName{ivar};
    59    eval(['SubData.' VarName '=Field.' VarName ';'])
    60 end
    61 
    62 %fields     
     63   SubData.(VarName)=Field.(VarName);
     64end
     65
     66%% check the two input fields     
    6367[CellVarIndex,NbDim,VarTypeCell,errormsg]=find_field_indices(Field);
    6468if ~isempty(errormsg)
     
    111115end
    112116
    113 %substract two vector fields or two scalars
     117%% substract two vector fields or two scalars
    114118if (testU && testU_1) || (~testU && ~testU_1)
    115119   %check coincidence in positions
     
    118122       XName=Field.ListVarName{VarType.coord_x};
    119123       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);
    122126       nbpoints=numel(vec_X);
    123127       vec_X=reshape(vec_X,nbpoints,1);
     
    361365                VName_1_1=[VName_1 '_1'];
    362366        end
    363     end     
     367    end   
     368   
    364369    if ~testX_1
    365370          DimCell=[{XName_1_1} {YName_1_1}];
     
    376381        SubData.VarAttribute=[SubData.VarAttribute {XAttr} {YAttr} {UAttr} {VAttr}];
    377382    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);
    382387end
    383388 
Note: See TracChangeset for help on using the changeset viewer.