Index: /trunk/src/calc_field_tps.m
===================================================================
--- /trunk/src/calc_field_tps.m	(revision 865)
+++ /trunk/src/calc_field_tps.m	(revision 866)
@@ -121,7 +121,7 @@
         [EMDX,EMDY] = tps_eval_dxy(Coord_interp(ind_sel,:),Coord_tps(1:nbvec_sub,:,isub));%kernels for calculating the spatial derivatives from tps 'sources'
     end
-%     ListVar={};
     for ilist=1:length(FieldName)
-%         var_count=numel(ListVar);
+        %Operator{ilist}='';%default empty operator (vec, norm,...)
+        %r=regexp(FieldName{ilist},'(?<Operator>(^vec|^norm|^curl|^div|^strain))\((?<UName>.+),(?<VName>.+)\)$','names');% TODO, replace U, V
         switch FieldName{ilist}
             case 'vec(U,V)'
Index: /trunk/src/plot_field.m
===================================================================
--- /trunk/src/plot_field.m	(revision 865)
+++ /trunk/src/plot_field.m	(revision 866)
@@ -15,5 +15,5 @@
 %
 % OUPUT:
-% PlotType: type of plot: 'text','line'(curve plot),'plane':2D view,'volume'
+% PlotType: type of plot: 'text','line'(curve plot),'plane':2D view,'volume', or errormsg
 % PlotParamOut: structure, representing the updated  plotting parameters, in case of automatic scaling
 % haxes: handle of the plotting axis, when a new figure is created.
@@ -251,4 +251,5 @@
 %% display error message
 if ~isempty(errormsg)
+    PlotType=errormsg;
     msgbox_uvmat('ERROR', errormsg)
 end
@@ -637,5 +638,5 @@
     if isfield(CellInfo{icell},'VarIndex_vector_x')&&isfield(CellInfo{icell},'VarIndex_vector_y') % vector components detected
         if test_vec% a vector field has been already detected
-            errormsg='error in plot_field: attempt to plot two vector fields: to get the difference project on a plane with mode interp';
+            errormsg='error in plot_field: attempt to plot two vector fields: to get the difference project on a plane with ProjMode= interp_lin or interp_tps';
             return
         else
Index: /trunk/src/proj_field.m
===================================================================
--- /trunk/src/proj_field.m	(revision 865)
+++ /trunk/src/proj_field.m	(revision 866)
@@ -120,4 +120,39 @@
 end
 
+% %% take the difference of projected input fields if relevant
+% [CellInfo,NbDim,errormsg]=find_field_cells(ProjData);
+% ind_remove=zeros(size(ProjData.ListVarName));
+% ivar=[];
+% ivar_1=[];
+% for icell=1:numel(CellInfo)
+%     if ~isempty(CellInfo{icell})
+%         % if two scalar are in the same cell
+%         if isfield(CellInfo{icell},'VarIndex_scalar') && numel(CellInfo{icell}.VarIndex_scalar)==2 && ProjData.VarAttribute{CellInfo{icell}.VarIndex_scalar(2)}.CheckSub;
+%             ivar=[ivar CellInfo{icell}.VarIndex_scalar(1)];
+%             ivar_1=[ivar_1 CellInfo{icell}.VarIndex_scalar(2)];
+%         end
+%         % if two vector u components are in the same cell
+%         if isfield(CellInfo{icell},'VarIndex_vector_x') && numel(CellInfo{icell}.VarIndex_vector_x)==2 && ProjData.VarAttribute{CellInfo{icell}.VarIndex_vector_x(2)}.CheckSub;
+%             ivar=[ivar CellInfo{icell}.VarIndex_vector_x(1)];
+%             ivar_1=[ivar_1 CellInfo{icell}.VarIndex_vector_x(2)];
+%         end
+%          % if two vector v components are in the same cell
+%         if isfield(CellInfo{icell},'VarIndex_vector_y') && numel(CellInfo{icell}.VarIndex_vector_y)==2 && ProjData.VarAttribute{CellInfo{icell}.VarIndex_vector_y(2)}.CheckSub;
+%             ivar=[ivar CellInfo{icell}.VarIndex_vector_y(1)];
+%             ivar_1=[ivar_1 CellInfo{icell}.VarIndex_vector_y(2)];
+%         end
+%     end
+% end
+% % subtract fields if relevant
+% for imod=1:numel(ivar)
+%         VarName=ProjData.ListVarName{ivar(imod)};
+%         VarName_1=ProjData.ListVarName{ivar_1(imod)};
+%         ProjData.(VarName)=double(ProjData.(VarName))-double(ProjData.(VarName_1));
+%         ind_remove(ivar_1(imod))=1;
+% end
+% ProjData.ListVarName(find(ind_remove))=[];
+% ProjData.VarDimName(find(ind_remove))=[];
+% ProjData.VarAttribute(find(ind_remove))=[];
+
 %-----------------------------------------------------------------
 %project on a set of points
@@ -387,6 +422,6 @@
             XName=FieldData.ListVarName{ivar_X};
             YName=FieldData.ListVarName{ivar_Y};
-            coord_x=FieldData.(XName);
-            coord_y=FieldData.(YName);
+            coord_x=FieldData.(FieldData.ListVarName{ivar_X});
+            coord_y=FieldData.(FieldData.ListVarName{ivar_Y});
             % image or 2D matrix
         case 'grid' %case of structured coordinates
@@ -584,6 +619,6 @@
                 costheta=cos(theta(isegment));
                 sintheta=sin(theta(isegment));
-%                 XIsegment=LineCoord(isegment,1)+DX_edge*costheta:DX*costheta:LineCoord(isegment+1,1));
-%                 YIsegment=(LineCoord(isegment,2)+DX_edge*sintheta:DX*sintheta:LineCoord(isegment+1,2));
+                %                 XIsegment=LineCoord(isegment,1)+DX_edge*costheta:DX*costheta:LineCoord(isegment+1,1));
+                %                 YIsegment=(LineCoord(isegment,2)+DX_edge*sintheta:DX*sintheta:LineCoord(isegment+1,2));
                 NbInterval=floor((dlength(isegment)-DX_edge)/DX);
                 LastX=DX_edge+DX*NbInterval;
@@ -618,4 +653,5 @@
 ProjData.ListVarName={};
 ProjData.VarDimName={};
+check_abscissa=0;
 for icell=1:length(CellInfo)
     % list of variable types to be projected
@@ -631,10 +667,10 @@
     %% identify vector components
     testU=isfield(CellInfo{icell},'VarIndex_vector_x') &&isfield(CellInfo{icell},'VarIndex_vector_y') ;% test for vectors
-%     if testU
-%         UName=FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_x};
-%         VName=FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_y};
-%         vector_x=FieldData.(UName);
-%         vector_y=FieldData.(VName);
-%     end
+    %     if testU
+    %         UName=FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_x};
+    %         VName=FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_y};
+    %         vector_x=FieldData.(UName);
+    %         vector_y=FieldData.(VName);
+    %     end
     %identify error flag
     errorflag=0; %default, no error flag
@@ -654,12 +690,9 @@
         %case of unstructured coordinates
         case 'scattered'
-            XName= FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)};
-            YName= FieldData.ListVarName{CellInfo{icell}.CoordIndex(end-1)};
-            coord_x=FieldData.(XName);
-            coord_y=FieldData.(YName);
-            ProjData.ListVarName=[ProjData.ListVarName {XName}];
-            ProjData.VarDimName=[ProjData.VarDimName {XName}];
-            nbvar=numel(ProjData.ListVarName);
-            ProjData.VarAttribute{nbvar}.long_name='abscissa along line';
+%             XName= FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)};
+%             YName= FieldData.ListVarName{CellInfo{icell}.CoordIndex(end-1)};
+            coord_x=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)});
+            coord_y=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(end-1)});
+            
             if isequal(ProjMode,'projection')
                 if width==0
@@ -667,4 +700,8 @@
                     return
                 end
+                ProjData.ListVarName=[ProjData.ListVarName {FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)}}];
+                ProjData.VarDimName=[ProjData.VarDimName {FieldData.ListVarName{CellInfo{icell}.CoordIndex(end-1)}}];
+                nbvar=numel(ProjData.ListVarName);
+                ProjData.VarAttribute{nbvar}.long_name='abscissa along line';
                 % select the (non false) input data located in the band of projection
                 flagsel=(errorflag==0) & ((coord_y -yinf(1))*(xinf(2)-xinf(1))>(coord_x-xinf(1))*(yinf(2)-yinf(1))) ...
@@ -678,10 +715,10 @@
                 Xproj=(coord_x-ObjectData.Coord(1,1))*costheta + (coord_y-ObjectData.Coord(1,2))*sintheta; %projection on the line
                 [Xproj,indsort]=sort(Xproj);% sort points by increasing absissa along the projection line
-                ProjData.(XName)=Xproj;
+                ProjData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)})=Xproj;
                 for ivar=1:numel(VarIndex)
                     ProjData.(VarName{ivar})=FieldData.(VarName{ivar})(flagsel);% restrict vrtibles to the projection band
                     ProjData.(VarName{ivar})=ProjData.(VarName{ivar})(indsort);% sort by absissa
                     ProjData.ListVarName=[ProjData.ListVarName VarName{ivar}];
-                    ProjData.VarDimName=[ProjData.VarDimName {XName}];
+                    ProjData.VarDimName=[ProjData.VarDimName {FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)}}];
                     ProjData.VarAttribute{nbvar+ivar}=FieldData.VarAttribute{VarIndex(ivar)};%reproduce var attribute
                     if isfield(ProjData.VarAttribute{nbvar+ivar},'Role')
@@ -695,4 +732,12 @@
                 end
             elseif isequal(ProjMode,'interp_lin')  %filtering %linear interpolation:
+                if ~check_abscissa
+                    XName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)};
+                    ProjData.ListVarName=[ProjData.ListVarName {XName}];
+                    ProjData.VarDimName=[ProjData.VarDimName {XName}];
+                    nbvar=numel(ProjData.ListVarName);
+                    ProjData.VarAttribute{nbvar}.long_name='abscissa along line';
+                    check_abscissa=1; % define abcissa only once
+                end
                 if ~isequal(errorflag,0)
                     VarName_FF=FieldData.ListVarName{CellInfo{icell}.VarIndex_errorflag};
@@ -704,7 +749,8 @@
                         FieldData.(VarName)=FieldData.(VarName)(indsel);
                     end
-                end                    
+                end
                 [ProjVar,ListFieldProj,VarAttribute,errormsg]=calc_field_interp([coord_x coord_y],FieldData,CellInfo{icell}.FieldName,XI,YI);
                 ProjData.X=Xproj;
+                nbvar=numel(ProjData.ListVarName);
                 ProjData.ListVarName=[ProjData.ListVarName ListFieldProj];
                 ProjData.VarAttribute=[ProjData.VarAttribute VarAttribute];
@@ -713,7 +759,7 @@
                     if isfield(VarAttribute{ivar},'Role')
                         if  strcmp(VarAttribute{ivar}.Role,'vector_x');
-                            ivar_U=ivar;
+                            ivar_U=ivar+nbvar;
                         elseif strcmp(VarAttribute{ivar}.Role,'vector_y');
-                            ivar_V=ivar;
+                            ivar_V=ivar+nbvar;
                         end
                     end
@@ -741,7 +787,7 @@
                     if isfield(VarAttribute{ivar},'Role')
                         if  strcmp(VarAttribute{ivar}.Role,'vector_x');
-                            ivar_U=ivar;
+                            ivar_U=ivar+nbvar;
                         elseif strcmp(VarAttribute{ivar}.Role,'vector_y');
-                            ivar_V=ivar;
+                            ivar_V=ivar+nbvar;
                         end
                     end
@@ -861,11 +907,10 @@
                 end
             end
-    end 
+    end
     if ~isempty(ivar_U) && ~isempty(ivar_V)
-        vector_x =ProjData.(ProjData.ListVarName{nbvar+ivar_U});
-         ProjData.(ProjData.ListVarName{nbvar+ivar_U}) =cos(theta)*vector_x+sin(theta)*ProjData.(ProjData.ListVarName{nbvar+ivar_V});
-          ProjData.(ProjData.ListVarName{nbvar+ivar_V}) =-sin(theta)*vector_x+cos(theta)*ProjData.(ProjData.ListVarName{nbvar+ivar_V});
-    end
-        
+        vector_x =ProjData.(ProjData.ListVarName{ivar_U});
+        ProjData.(ProjData.ListVarName{ivar_U}) =cos(theta)*vector_x+sin(theta)*ProjData.(ProjData.ListVarName{ivar_V});
+        ProjData.(ProjData.ListVarName{ivar_V}) =-sin(theta)*vector_x+cos(theta)*ProjData.(ProjData.ListVarName{ivar_V});
+    end
 end
 
@@ -1230,6 +1275,8 @@
                     
                     if isfield(CellInfo{icell},'CheckSub') && CellInfo{icell}.CheckSub && ~isempty(vector_x_proj)
-                        ProjData.(ListVarName{vector_x_proj})=ProjData.(ListVarName{vector_x_proj})-VarVal{1};
-                        ProjData.(ListVarName{vector_y_proj})=ProjData.(ListVarName{vector_y_proj})-VarVal{2};
+                        ProjData.(FieldData.ListVarName{vector_x_proj})=ProjData.(FieldData.ListVarName{vector_x_proj})-VarVal{1};
+                        ProjData.(FieldData.ListVarName{vector_y_proj})=ProjData.(FieldData.ListVarName{vector_y_proj})-VarVal{2};
+                        ListVarName={};% no new variable
+                        VarAttribute={};
                     else
                         VarDimName=cell(size(ListVarName));
@@ -1243,4 +1290,6 @@
                         end
                     end
+                    vector_x_proj=CellInfo{icell}.VarIndex_vector_x; %preserve for next cell
+                    vector_y_proj=CellInfo{icell}.VarIndex_vector_y; %preserve for next cell
             end
             
@@ -1491,8 +1540,8 @@
                             ListVarName=[ListVarName VarName];
                             VarAttribute{length(ListVarName)}=FieldData.VarAttribute{ivar}; %reproduce the variable attributes
-                            eval(['ProjData.' VarName '=squeeze(FieldData.' VarName '(iz,:,:));'])% select the z index iz
+                            ProjData.(VarName)=squeeze(FieldData.(VarName)(iz,:,:));% select the z index iz
                             %TODO : do a vertical average for a thick plane
                             if test_interp(2) || test_interp(3)
-                                eval(['ProjData.' VarName '=interp2(Coord{3},Coord{2},ProjData.' VarName ',Coord_x,Coord_y'');'])
+                                ProjData.(VarName)=interp2(Coord{3},Coord{2},ProjData.(VarName),Coord_x,Coord_y);
                             end
                         end
@@ -1535,6 +1584,6 @@
                 if ~isempty(ivar_W)
                     WName=FieldData.ListVarName{ivar_W};
-                    eval(['ProjData.' VName '=ProjData.' VName '+ ProjData.' WName '*sin(Theta);'])%
-                    eval(['ProjData.' WName '=NormVec_X*ProjData.' UName '+ NormVec_Y*ProjData.' VName '+ NormVec_Z* ProjData.' WName ';']);
+                    ProjData.(VName)=ProjData.(VName)+ ProjData.(WName)*sin(Theta);%
+                    ProjData.(WName)=NormVec_X*ProjData.(UName)+ NormVec_Y*ProjData.(VName)+ NormVec_Z* ProjData.(WName);
                 end
             end
Index: /trunk/src/sub_field.m
===================================================================
--- /trunk/src/sub_field.m	(revision 865)
+++ /trunk/src/sub_field.m	(revision 866)
@@ -125,9 +125,9 @@
 
 %% look for coordinates common to Field in Field_1
-ind_remove=zeros(size(Field_1.ListVarName));
+ind_remove=false(size(Field_1.ListVarName));
 % loop on the variables of the second field Field_1
 for ilist=1:numel(Field_1.ListVarName)
     % case of variable with a single dimension
-    if ~isempty(regexp(Field_1.VarAttribute{ilist}.Role,'^coord'))
+    if ~isempty(Field_1.VarAttribute{ilist}) && ~isempty(regexp(Field_1.VarAttribute{ilist}.Role,'^coord'))% if variable with Role coord... is found.
         OldDimName=Field_1.VarDimName{ilist};
         if ischar(OldDimName), OldDimName={OldDimName}; end% transform char string to cell if relevant
@@ -147,64 +147,86 @@
     end
 end
-Field_1.ListVarName(find(ind_remove))=[];%removes the redondent coordinate
-Field_1.VarDimName(find(ind_remove))=[];
-Field_1.VarAttribute(find(ind_remove))=[];
+if ~isempty(find(ind_remove, 1))
+Field_1.ListVarName(ind_remove)=[];%removes the redondent coordinate
+Field_1.VarDimName(ind_remove)=[];
+Field_1.VarAttribute(ind_remove)=[];
+end
 
 %% append the other variables of the second field, modifying their name if needed
-ListVarNameNew=Field_1.ListVarName;
-check_rename=zeros(size(ListVarNameNew));
-check_remove=zeros(size(ListVarNameNew));
-for ilist=1:numel(ListVarNameNew)
-    VarName=Field_1.ListVarName{ilist};
-    ind_prev=find(strcmp(ListVarNameNew{ilist},Field.ListVarName),1);% look for duplicated variable name
+ListVarNameSub=Field_1.ListVarName;
+ListVarNameNew=ListVarNameSub;
+check_rename=zeros(size(ListVarNameSub));
+check_remove=zeros(size(ListVarNameSub));
+for ilist=1:numel(ListVarNameSub)
+    ind_prev=find(strcmp(ListVarNameSub{ilist},Field.ListVarName),1);% look for duplicated variable name
     if ~isempty(ind_prev)% variable name exists in Field
-%         check_rename(ilist)=0;
-        check_remove(ilist)=1;
-        if isfield(Field_1.VarAttribute{ilist},'Role')&& ismember(Field_1.VarAttribute{ilist}.Role,{'scalar','vector_x','vector_y'})
-                            ListVarNameNew{ilist}=[ListVarNameNew{ilist} '_1'];
-                            check_rename(ilist)=1;
-        end
-    end
-    SubData.ListVarName=[SubData.ListVarName ListVarNameNew{ilist}];
-    SubData.VarDimName=[SubData.VarDimName Field_1.VarDimName(ilist)];
-    Field_1.VarAttribute{ilist}.CheckSub=1;
-    SubData.VarAttribute=[SubData.VarAttribute Field_1.VarAttribute{ilist}];
-    SubData.(ListVarNameNew{ilist})=Field_1.(VarName);% teke the values of the old variable for the newly named one
-    %SubData.VarAttribute=[SubData.VarAttribute Field_1.VarDimName(ilist)];
-end
-
-%% replace variable name in field expression FieldName, e.g. 'norm(U,V)'-> 'norm(U_1,V_1)'
-for ilist=1:numel(ListVarNameNew)
-    if check_rename(ilist)&&  isfield(Field_1.VarAttribute{ilist},'FieldName')
-        for ivar=1:numel(find(check_rename))
-            Field_1.VarAttribute{ilist}.FieldName=regexprep_r(Field_1.VarAttribute{ilist}.FieldName,...
-                Field_1.ListVarName{ivar},ListVarNameNew{ivar});
-        end
-    end
-    SubData.VarAttribute=[SubData.VarAttribute Field_1.VarAttribute(ilist)];
-    SubData.VarAttribute{end}.CheckSub=1;% mark that the field needs to be substracted as an attribute
-end
+        if isfield(Field_1.VarAttribute{ilist},'Role')&&...
+            ismember(Field_1.VarAttribute{ilist}.Role,{'coord_x','coord_y','scalar','vector_x','vector_y','errorflag'})
+            ListVarNameNew{ilist}=[ListVarNameSub{ilist} '_1'];%modify the name of the second variable
+            check_rename(ilist)=1;
+        else
+            check_remove(ilist)=1;% variable will be removed
+        end
+    end
+end
+ListVarNameSub=ListVarNameSub(~check_remove); %eliminate removed variables from the list of the second field
+ListVarNameNew=ListVarNameNew(~check_remove); % %list of renaimed varaibles corresponding to ListVarNameSub
+VarDimNameSub=Field_1.VarDimName(~check_remove);
+VarAttributeSub=Field_1.VarAttribute(~check_remove);
+check_rename=check_rename(~check_remove); 
+
+% apply the variable renaming and mark the second field variables with the attribute .CheckSub
+for ilist=1:numel(ListVarNameSub)
+     SubData.(ListVarNameNew{ilist})=Field_1.(ListVarNameSub{ilist});% copy the variable content to the new name
+    if check_rename(ilist)   
+          % replace name in field expression FieldName, e.g. 'norm(U,V)'-> 'norm(U_1,V_1)'
+        if  isfield(VarAttributeSub{ilist},'FieldName')
+            for ivar=1:numel(find(check_rename))
+                VarAttributeSub{ilist}.FieldName=regexprep_r(VarAttributeSub{ilist}.FieldName,...
+                    ListVarNameSub{ivar},ListVarNameNew{ivar});
+            end
+        end
+    end
+    VarAttributeSub{ilist}.CheckSub=1;% mark that the field needs to be substracted as an attribute
+end
+
+SubData.ListVarName=[SubData.ListVarName ListVarNameNew];
+SubData.VarDimName=[SubData.VarDimName VarDimNameSub];
+SubData.VarAttribute=[SubData.VarAttribute VarAttributeSub];
 
 %% substrat fields when possible
 [CellInfo,NbDim,errormsg]=find_field_cells(SubData);
-ind_remove=zeros(size(SubData.ListVarName));
+ind_remove=false(size(SubData.ListVarName));
 ivar=[];
 ivar_1=[];
 for icell=1:numel(CellInfo)
     if ~isempty(CellInfo{icell})
+        % if two scalar are in the same cell
         if isfield(CellInfo{icell},'VarIndex_scalar') && numel(CellInfo{icell}.VarIndex_scalar)==2 && SubData.VarAttribute{CellInfo{icell}.VarIndex_scalar(2)}.CheckSub;
             ivar=[ivar CellInfo{icell}.VarIndex_scalar(1)];
             ivar_1=[ivar_1 CellInfo{icell}.VarIndex_scalar(2)];
         end
+        % if two vector u components are in the same cell
         if isfield(CellInfo{icell},'VarIndex_vector_x') && numel(CellInfo{icell}.VarIndex_vector_x)==2 && SubData.VarAttribute{CellInfo{icell}.VarIndex_vector_x(2)}.CheckSub;
             ivar=[ivar CellInfo{icell}.VarIndex_vector_x(1)];
             ivar_1=[ivar_1 CellInfo{icell}.VarIndex_vector_x(2)];
         end
+         % if two vector v components are in the same cell
         if isfield(CellInfo{icell},'VarIndex_vector_y') && numel(CellInfo{icell}.VarIndex_vector_y)==2 && SubData.VarAttribute{CellInfo{icell}.VarIndex_vector_y(2)}.CheckSub;
             ivar=[ivar CellInfo{icell}.VarIndex_vector_y(1)];
             ivar_1=[ivar_1 CellInfo{icell}.VarIndex_vector_y(2)];
         end
-    end
-end
+        % merge the error flags if needed
+        if isfield(CellInfo{icell},'VarIndex_errorflag') && numel(CellInfo{icell}.VarIndex_errorflag)==2 && SubData.VarAttribute{CellInfo{icell}.VarIndex_vector_y(2)}.CheckSub;
+            ivar_flag=CellInfo{icell}.VarIndex_errorflag(1);
+            ivar_flag_1=CellInfo{icell}.VarIndex_errorflag(2);
+            VarName=SubData.ListVarName{ivar_flag};
+            VarName_1=SubData.ListVarName{ivar_flag_1};
+            SubData.(VarName)=SubData.(VarName)~=0 | SubData.(VarName_1)~=0;% combine the error flags of the two fields
+            ind_remove(ivar_flag_1)=1;
+        end
+    end
+end
+% subtract fields if relevant
 for imod=1:numel(ivar)
         VarName=SubData.ListVarName{ivar(imod)};
@@ -213,7 +235,7 @@
         ind_remove(ivar_1(imod))=1;
 end
-SubData.ListVarName(find(ind_remove))=[];
-SubData.VarDimName(find(ind_remove))=[];
-SubData.VarAttribute(find(ind_remove))=[];
+SubData.ListVarName(ind_remove)=[];
+SubData.VarDimName(ind_remove)=[];
+SubData.VarAttribute(ind_remove)=[];
 
 function OutputCell=regexprep_r(InputCell,search_string,new_string)
Index: /trunk/src/transform_field/phys.m
===================================================================
--- /trunk/src/transform_field/phys.m	(revision 865)
+++ /trunk/src/transform_field/phys.m	(revision 866)
@@ -116,8 +116,9 @@
         return %bad calib parameter input
     end
-    if ~(isfield(DataIn_1,'CoordUnit')&& strcmp(DataIn_1.CoordUnit,'pixel'))
-        return % transform only fields in pixel coordinates
-    end
+    if (isfield(DataIn_1,'CoordUnit')&& strcmp(DataIn_1.CoordUnit,'pixel'))
+%         return % transform only fields in pixel coordinates
+%     end
     DataOut_1=phys_1(DataOut_1,Calib{2},ZIndex);
+    end
     if isfield(Calib{1},'SliceCoord')
         if ~(isfield(Calib{2},'SliceCoord') && isequal(Calib{2}.SliceCoord,Calib{1}.SliceCoord))
Index: /trunk/src/uvmat.m
===================================================================
--- /trunk/src/uvmat.m	(revision 865)
+++ /trunk/src/uvmat.m	(revision 866)
@@ -3283,5 +3283,5 @@
             if ischar(list_fields),list_fields={list_fields};end
             FieldName_1= list_fields{get(handles.FieldName_1,'Value')}; % selected field
-            if ~strcmp(FieldName,'get_field...')
+            if ~strcmp(FieldName_1,'get_field...')
                 if get(handles.FixVelType,'Value')
                     VelTypeList=get(handles.VelType_1,'String');
@@ -3289,5 +3289,8 @@
                 end
             end
-            if strcmp(FieldName_1,'velocity')&& strcmp(get(handles.ColorCode,'Visible'),'on')
+            if isempty(FieldName_1)
+                FieldName_1=FieldName;% if blank reproduce the field name of the first field
+            end
+            if ~isempty(regexp(FieldName_1,'^vel'))&& strcmp(get(handles.ColorCode,'Visible'),'on')
                 list_code=get(handles.ColorCode,'String');% list menu fields
                 index_code=get(handles.ColorCode,'Value');% selected string index
@@ -3759,4 +3762,16 @@
             else
                 [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap});
+                if ~isempty(regexp(PlotType,'^error'))
+                    if ~isempty(regexp(PlotType,'attempt to plot two vector fields'))
+                        set(handles.CheckEditObject,'Value',1)
+                        CheckEditObject_Callback([], [], handles)
+                        hset_object=findobj(allchild(0),'Tag','set_object');%find the GUI set_object
+                        hhset_object=guidata(hset_object);%
+                        set(hhset_object.ProjMode,'Value',2);
+                        set_object('ProjMode_Callback',hset_object,[],hhset_object); 
+                    end
+%                     errormsg=PlotType;
+                    return
+                end
                 if imap==1
                     errormsg=fill_GUI(PlotParamOut,handles.uvmat);
@@ -4459,20 +4474,4 @@
             REFRESH_Callback(hObject, eventdata, handles)
         end
-          
-%         set_veltype_display(0) % no veltype display
-%         hget_field=findobj(allchild(0),'name','get_field_1');
-%         if ~isempty(hget_field)
-%             delete(hget_field)
-%         end
-%         hget_field=get_field(FileName_1);
-%         set(hget_field,'name','get_field_1')
-%         hhget_field=guidata(hget_field);
-%         set(hhget_field.list_fig,'Value',1)
-%         set(hhget_field.list_fig,'String',{'uvmat'})
-%         if check_new
-%             UvData.FileType{2}=UvData.FileType{1};
-%             set(handles.FileIndex_1,'String',get(handles.FileIndex,'String'))
-%               set(handles.uvmat,'UserData',UvData)
-%         end
     case 'image'
         %% look for image corresponding to civ data
