Index: /trunk/src/civ.m
===================================================================
--- /trunk/src/civ.m	(revision 412)
+++ /trunk/src/civ.m	(revision 413)
@@ -3937,21 +3937,22 @@
 
 %------------------------------------------------------------------------
-% --- Executes on button press in TestCiv1: display image correlation function
+% --- Executes on button press in TestCiv1: prepare the image correlation function
+% activated by mouse motion
 function TestCiv1_Callback(hObject, eventdata, handles)
 %------------------------------------------------------------------------
-set(handles.TestCiv1,'BackgroundColor',[1 1 0])
 drawnow
 if get(handles.TestCiv1,'Value')
-    ref_i=str2double(get(handles.ref_i,'String'));
+    set(handles.TestCiv1,'BackgroundColor',[0.7 0.7 0.7])% paint TestCiv1 button to grey to confirm civ launch
+    ref_i=str2double(get(handles.ref_i,'String'));% read reference i index
     if strcmp(get(handles.ref_j,'Visible'),'on')
-        ref_j=str2double(get(handles.ref_j,'String'));
+        ref_j=str2double(get(handles.ref_j,'String'));% read reference j index if relevant
     else
-        ref_j=1;%default
-    end
-    [filecell,i1,i21,j1,j2,i1_civ2,i2_civ2,j1_civ2,j2_civ2,nom_type_nc,file_ref_fix1,file_ref_fix2]=...
-        set_civ_filenames(handles,ref_i,ref_j,[1 0 0 0 0 0]);
+        ref_j=1;%default j index
+    end
+    [filecell,i1,i2,j1,j2,i1_civ2,i2_civ2,j1_civ2,j2_civ2,nom_type_nc,file_ref_fix1,file_ref_fix2]=...
+        set_civ_filenames(handles,ref_i,ref_j,[1 0 0 0 0 0]);% get the corresponding file name and indices
     Data.ListVarName={'ny','nx','A'};
     Data.VarDimName= {'ny','nx',{'ny','nx'}};
-    Data.A=imread(filecell.ima1.civ1{1});
+    Data.A=imread(filecell.ima1.civ1{1}); % read the first image
     if ndims(Data.A)==3 %case of color image
         Data.VarDimName= {'ny','nx',{'ny','nx','rgb'}};
@@ -3959,10 +3960,11 @@
     Data.ny=[size(Data.A,1) 1];
     Data.nx=[1 size(Data.A,2)];
+    Data.CoordUnit='pixel';% used to set equal scaling for x and y in image dispaly
     par_civ1=read_GUI(handles.Civ1);
     par_civ1.ImageWidth=size(Data.A,2);
     par_civ1.ImageHeight=size(Data.A,1);
     par_civ1.Mask='all';% will provide only the grid set for PIV, no image correlation
-    par_civ1.i1=1;%i1_civ1;
-    par_civ1.i2=2;%i2_civ1;
+    par_civ1.i1=i1;
+    par_civ1.i2=i2;
     Param.Civ1=par_civ1;
     Grid=civ_matlab(Param);% get the grid of x, y positions set for PIV 
@@ -3986,4 +3988,5 @@
     set(handles.TestCiv1,'BackgroundColor',[1 0 0])
 else
+    set(handles.TestCiv1,'BackgroundColor',[1 0 0])% paint button to red
     corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display
     if ~isempty(corrfig)
Index: /trunk/src/mouse_down.m
===================================================================
--- /trunk/src/mouse_down.m	(revision 412)
+++ /trunk/src/mouse_down.m	(revision 413)
@@ -40,4 +40,5 @@
     test_zoom=0;
 end
+test_piv=isfield(FigData,'CivHandle');
 
 %% look for parameters set by the GUI uvmat
@@ -52,9 +53,14 @@
     test_edit=get(hhuvmat.edit_object,'Value');%test for object editing, third priority
     test_edit_vect=get(hhuvmat.edit_vect,'Value');%test for vector editing,  priority 4
-    test_create=isequal(get(hhuvmat.MenuObject,'checked'),'on');% test for object creation,  priority 5
-    if test_create
-        hset_object=findobj(allchild(0),'tag','set_object');
-        test_create=~isempty(hset_object)&&~test_edit;
-    end
+    %     test_create=isequal(get(hhuvmat.MenuObject,'checked'),'on');% test for object creation,  priority 5
+    %     if test_create
+    test_create=0;
+    hset_object=findobj(allchild(0),'tag','set_object');
+    if ~isempty(hset_object)
+        hPLOT=findobj(hset_object,'tag','PLOT');
+        test_create=strcmp(get(hPLOT,'enable'),'on') &&~test_edit;
+    end
+    %         test_create=~isempty(hset_object)&&~test_edit;
+    
     test_cal=isequal(get(hhuvmat.MenuCalib,'checked'),'on');% test for calibration
     if test_cal% test for calibration popints,  priority 6
@@ -194,4 +200,15 @@
 end
 
+%% PIV test
+if test_piv
+    figure
+    newaxes=axes;
+    copyobj(AxeData.CurrentCorrImage,newaxes);
+    set(newaxes,'CLim',[0 1])
+    copyobj(AxeData.CurrentVector,newaxes)
+    copyobj(AxeData.TitleHandle,newaxes)
+    colorbar
+end
+
 %% selection of an existing projection object (third priority)
 if  test_edit && (isequal(tag_obj,'proj_object')||isequal(tag_obj,'DeformPoint'))
Index: /trunk/src/mouse_motion.m
===================================================================
--- /trunk/src/mouse_motion.m	(revision 412)
+++ /trunk/src/mouse_motion.m	(revision 413)
@@ -212,5 +212,6 @@
                         xround=Field.X(ind_pt);
                         yround=Field.Y(ind_pt);
-                        par.Grid=[xround size(Field.A,1)-yround+1];
+%                         par.Grid=[xround size(Field.A,1)-yround+1];
+                        par.Grid=[xround yround];
                         % mark the correlation box with a rectangle
                         par.ImageA=Field.A;
@@ -258,7 +259,8 @@
                                 corrfig=findobj(allchild(0),'tag','corrfig');
                                 if ~isempty(corrfig)
-                                    set(0,'CurrentFigure',corrfig(1))
+                                    set(0,'CurrentFigure',corrfig(1))         
                                     AxeData.CurrentCorrImage=imagesc(rangx,-rangy,result_conv,[0 1]);
                                     AxeData.CurrentVector=line([0 Data.Civ1_U],[0 Data.Civ1_V],'Tag','vector');
+                                   AxeData.TitleHandle=title(num2str(par.Grid));
                                     colorbar
                                     set(haxes,'UserData',AxeData)
@@ -270,4 +272,5 @@
                                 set(AxeData.CurrentCorrImage,'YData',-rangy)
                                 set(AxeData.CurrentVector,'XData',[0 Data.Civ1_U],'YData',[0 Data.Civ1_V])
+                                set(AxeData.TitleHandle,'String',num2str(par.Grid))
                             end
                         end
Index: /trunk/src/mouse_up.m
===================================================================
--- /trunk/src/mouse_up.m	(revision 412)
+++ /trunk/src/mouse_up.m	(revision 413)
@@ -152,20 +152,24 @@
             ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData
             if ~isempty(ProjData)
-                if strcmp(tagfig,'uvmat')% uvmat plot selected, projection plot seen on view_field
+                if strcmp(tagfig,'uvmat')% uvmat plot selected, projection plot seen in view_field
                     hview_field=findobj(allchild(0),'tag','view_field');
                     if isempty(hview_field)
-                        hview_field=view_field;
+                        hview_field=view_field(ProjData);
+                    else
+                       hhview_field=guidata(hview_field);
+                       [PlotType,PlotParam]=plot_field(ProjData,hhview_field.axes3,read_GUI(hview_field));%update an existing field plot
+                        write_plot_param(hhview_field,PlotParam); %update the display of plotting parameters for the current object
                     end
                     ViewFieldData=get(hview_field,'UserData');
                     ViewFieldData.axes3=ProjData;
                     set(hview_field,'UserData',ViewFieldData)
-                    hh_plotfield=guidata(hview_field);
+ 
                 else
                     UvData.axes3=ProjData;
-                    hh_plotfield=hhuvmat;
+                    [PlotType,PlotParam]=plot_field(ProjData,hhuvmat.axes3,read_GUI(hhuvmat));%update an existing field plot
+                    write_plot_param(hhuvmat,PlotParam); %update the display of plotting parameters for the current object
                 end
                 %[PlotType,PlotParam]=plot_field(ProjData,hh_plotfield.axes3,read_plot_param(hh_plotfield));%update an existing field plot
-                [PlotType,PlotParam]=plot_field(ProjData,hh_plotfield.axes3,read_GUI(hview_field));%update an existing field plot
-                write_plot_param(hh_plotfield,PlotParam); %update the display of plotting parameters for the current object
+
             end
             set(hhuvmat.edit_object,'BackgroundColor',[1 1 0]);% paint the edit text in yellow
Index: /trunk/src/set_object.m
===================================================================
--- /trunk/src/set_object.m	(revision 412)
+++ /trunk/src/set_object.m	(revision 413)
@@ -415,14 +415,4 @@
 function PLOT_Callback(hObject, eventdata, handles)
 
-%% reading the object selection in the GUI uvmat
-huvmat=findobj('tag','uvmat');%find the current uvmat GUI handle
-UvData=get(huvmat,'UserData');%Data associated to the GUI uvmat 
-hhuvmat=guidata(huvmat);%handles of the objects children of the  GUI uvmat
-ListObject=get(hhuvmat.ListObject,'String');% list of objects displyed in uvmat
-IndexObj(1)=get(hhuvmat.ListObject_1,'Value');% index of the selected object for display in uvmat
-if get(hhuvmat.ViewObject,'Value') 
-    IndexObj(2)=get(hhuvmat.ListObject,'Value');% index of the object, possibly selected for display in view_field 
-end
-
 %% read the object parameters in the GUI set_object
 ObjectData=read_GUI(handles.set_object);%read the parameters defining the object in the GUI set_object
@@ -438,13 +428,15 @@
 ObjectName=ObjectData.Name;%name of the current object defined in set_object
 if isempty(ObjectName)
-%     if get(hhuvmat.edit_object,'Value')% edit mode
-%         if isempty(ListObject)
-%             ObjectName='Plane';
-%         else
-%             ObjectName=ListObject{IndexObj(end)};%take the name of the last (second) selected item
-%         end
-%     else %new object
-        ObjectName=ObjectData.Type;
-%     end
+     ObjectName=ObjectData.Type;
+end
+
+%% read the object selection in the GUI uvmat
+huvmat=findobj('tag','uvmat');%find the current uvmat GUI handle
+UvData=get(huvmat,'UserData');%Data associated to the GUI uvmat 
+hhuvmat=guidata(huvmat);%handles of the objects children of the  GUI uvmat
+ListObject=get(hhuvmat.ListObject_1,'String');% list of objects displayed in uvmat
+IndexObj(1)=get(hhuvmat.ListObject_1,'Value');% index of the selected object for display in uvmat
+if get(hhuvmat.ViewObject,'Value') && get(hhuvmat.edit_object,'Value')
+    IndexObj(2)=get(hhuvmat.ListObject,'Value');% index of the object, possibly selected for display in view_field 
 end
 if ~get(hhuvmat.edit_object,'Value') %new object is being created
@@ -473,45 +465,28 @@
     UvData.Object{IndexObj(2)}=[];%initiate a new object (empty yet)
 end
-testnew=0;
-if numel(IndexObj)==1   % if only one object is selected, the projection is in uvmat
-    plotaxes=hhuvmat.axes3;%handle of axes3 in view_field
-else  % if a second object is selected, the projection is in view_field, and this second object is selected
-    hview_field=findobj(allchild(0),'tag','view_field');
-    if isempty(hview_field)
-        hview_field=view_field;%open the GUI view_field if it is not found
-    end
-    PlotHandles=guidata(hview_field);
-    plotaxes=PlotHandles.axes3;%handle of axes3 in view_field
-end 
 
 %% naming the object
-ListObject{IndexObj(end),1}=ObjectName;
-set(hhuvmat.ListObject,'String',ListObject)
-set(hhuvmat.ListObject_1,'String',ListObject)
+% ListObject{IndexObj(end),1}=ObjectName;
+% set(hhuvmat.ListObject,'String',ListObject)
+% set(hhuvmat.ListObject_1,'String',ListObject)
 
 %% update the object plot 
-% if testnew
-%     set(hhuvmat.ListObject,'Value',IndexObj)
-%     ObjectData.DisplayHandle_uvmat=hhuvmat.axes3;
-%     ObjectData.DisplayHandle_view_field=[];
-% else
-    if IndexObj(end)<=length(UvData.Object) && isfield(UvData.Object{IndexObj(end)},'DisplayHandle_uvmat')% save the previous object graph handles
-        ObjectData.DisplayHandle_uvmat=UvData.Object{IndexObj(end)}.DisplayHandle_uvmat;
-    else
-        ObjectData.DisplayHandle_uvmat=hhuvmat.axes3;%there is no object handle, than the axes handles is used as input
-    end
-    if isfield(UvData.Object{IndexObj(end)},'DisplayHandle_view_field')% save the previous object graph handles
-        ObjectData.DisplayHandle_view_field=UvData.Object{IndexObj(end)}.DisplayHandle_view_field;
-    else
-        ObjectData.DisplayHandle_view_field=[];
-    end
-% end
+if IndexObj(end)<=length(UvData.Object) && isfield(UvData.Object{IndexObj(end)},'DisplayHandle_uvmat')% save the previous object graph handles
+    ObjectData.DisplayHandle_uvmat=UvData.Object{IndexObj(end)}.DisplayHandle_uvmat;
+else
+    ObjectData.DisplayHandle_uvmat=hhuvmat.axes3;%there is no object handle, than the axes handles is used as input
+end
+if isfield(UvData.Object{IndexObj(end)},'DisplayHandle_view_field')% save the previous object graph handles
+    ObjectData.DisplayHandle_view_field=UvData.Object{IndexObj(end)}.DisplayHandle_view_field;
+else
+    ObjectData.DisplayHandle_view_field=[];
+end
 UvData.Object{IndexObj(end)}=ObjectData;%update the current object properties
- if numel(IndexObj)==2
+if numel(IndexObj)==2
     UvData.Object=update_obj(UvData,IndexObj(1),IndexObj(2));
- end
+end
 set(huvmat,'UserData',UvData)
 
-%% plot the field projected on the object and store in the corresponding figue
+%% plot the field projected on the object
 if strcmp(ObjectData.ProjMode,'mask_inside')||strcmp(ObjectData.ProjMode,'mask_outside')||strcmp(ObjectData.ProjMode,'none')
     PlotType='text';
@@ -521,8 +496,24 @@
         msgbox_uvmat('ERROR', errormsg)
         return
-    end
-    fighandle=get(plotaxes,'parent');
-    PlotParam=read_GUI(fighandle);
-    PlotType=plot_field(ProjData,plotaxes,PlotParam);%update an existing field plot
+    end   
+    if numel(IndexObj)==1   % if only one object is selected, the projection is in uvmat
+%         plotaxes=hhuvmat.axes3;%handle of axes3 in view_field
+        PlotType=plot_field(ProjData,hhuvmat.axes3,read_GUI(get(hhuvmat.axes3,'parent')));%update the current uvmat plot
+    else  % if a second object is selected, the projection is in view_field, and this second object is selected
+        hview_field=findobj(allchild(0),'tag','view_field');
+        if isempty(hview_field)
+            PlotType=view_field(ProjData); %open the view_field GUI for plot
+          %  hview_field=view_field;%open the GUI view_field if it is not found
+        else
+            hhview_field=guidata(hview_field);
+            [PlotType,PlotParam]=plot_field(ProjData,hhview_field.axes3,read_GUI(hview_field));%update an existing  plot in view_field
+            write_plot_param(hhview_field,PlotParam); %update the display of plotting parameters for the current object
+        end
+%         PlotHandles=guidata(hview_field);
+%         plotaxes=PlotHandles.axes3;%handle of axes3 in view_field
+    end
+%     fighandle=get(plotaxes,'parent');
+%     PlotParam=read_GUI(fighandle);
+   % PlotType=plot_field(ProjData,plotaxes,PlotParam);%update an existing field plot
 end
 if strcmp(PlotType,'text')
Index: /trunk/src/uvmat.m
===================================================================
--- /trunk/src/uvmat.m	(revision 412)
+++ /trunk/src/uvmat.m	(revision 413)
@@ -2513,9 +2513,6 @@
         return
     end
-    %     if testnewseries && isfield(ObjectData,'CoordUnit')&& isfield(PlotParam{imap},'Coordinates')
-    %         PlotParam{imap}.Coordinates=rmfield(PlotParam{imap}.Coordinates,'CheckFixEqual'); %set FixEqual to depend on the field (=1 if Data.CoordUnit=1 in plot_field)
-    %     end
     if testnewseries && isfield(ObjectData,'CoordUnit')
-        PlotParam{imap}.Coordinates.CheckFixEqual=1;
+        PlotParam{imap}.Coordinates.CheckFixEqual=1;% set x and y scaling equal if CoordUnit is defined (common unit for x and y)
     end
     %use of mask (TODO: check)
@@ -4425,5 +4422,5 @@
 hhset_object=guidata(hset_object);
 set(hhset_object.PLOT,'enable','on')% activate the refresh button
-set(handles.MenuObject,'checked','on')
+%set(handles.MenuObject,'checked','on')
 set(handles.uvmat,'UserData',UvData)
 set(handles.CheckZoom,'Value',0) %desactivate the zoom for object creation by the mouse
@@ -4456,5 +4453,5 @@
 set(handles.edit_object,'Value',0); %suppress the object edit mode
 set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7])  
-set(handles.MenuObject,'checked','on')
+%set(handles.MenuObject,'checked','on')
 set(handles.delete_object,'Visible','on')
 
Index: /trunk/src/view_field.m
===================================================================
--- /trunk/src/view_field.m	(revision 412)
+++ /trunk/src/view_field.m	(revision 413)
@@ -92,14 +92,12 @@
 AxeData.LimEditBox=1; %initialise AxeData, the parent figure sets plot parameters
 set(handles.axes3,'UserData',AxeData)
-if ~exist('Field','var')
-    return
-end
-[PlotType,PlotParamOut]= plot_field(Field,handles.axes3);%,PlotParam,KeepLim,PosColorbar)
-
-if isfield(PlotParamOut,'Vectors')
-    set(handles.Vectors,'Visible','on')
-end
-write_plot_param(handles,PlotParamOut);% update the display of the plotting parameters
-
+if exist('Field','var')
+    [PlotType,PlotParamOut]= plot_field(Field,handles.axes3);%,PlotParam,KeepLim,PosColorbar)
+    set(handles.Coordinates,'Visible','on')
+    if isfield(PlotParamOut,'Vectors')
+        set(handles.Vectors,'Visible','on')
+    end
+    write_plot_param(handles,PlotParamOut);% update the display of the plotting parameters
+end
 %------------------------------------------------------------------------
 % --- Outputs from this function are returned to the command menuline.
@@ -140,4 +138,14 @@
         end
     end
+end
+hciv=findobj(allchild(0),'Tag','civ');%find the current civ GUI
+if ~isempty(hciv)
+    hhciv=guidata(hciv);
+    set(hhciv.TestCiv1,'Value',0)% desactivate  TestCiv1 if on
+    set(hhciv.TestCiv1,'BackgroundColor',[1 0 0])% 
+end
+corrfig=findobj(allchild(0),'tag','corrfig');% look for a civ correlation window used with TesCiv1
+if ~isempty(corrfig)
+    delete(corrfig)
 end
 
@@ -317,5 +325,4 @@
 if test
     set(handles.CheckFixEqual,'BackgroundColor',[1 1 0])
-    cla(handles.axes3)
 else
     set(handles.CheckFixEqual,'BackgroundColor',[0.7 0.7 0.7])
@@ -328,68 +335,68 @@
 % --- Executes on button press in 'zoom'.
 %-------------------------------------------------------------------
-function zoom_Callback(hObject, eventdata, handles)
-if (get(handles.zoom,'Value') == 1); 
-    set(handles.zoom,'BackgroundColor',[1 1 0])
-    set(handles.FixLimits,'Value',1)% propose by default fixed limits for the plotting axes
-    set(handles.FixLimits,'BackgroundColor',[1 1 0])
-else
-    set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
-end
-
-%-------------------------------------------------------------------
-%----Executes on button press in 'record': records the current flags of manual correction.
-%-------------------------------------------------------------------
-function record_Callback(hObject, eventdata, handles)
-% [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles);
-filename=read_file_boxes(handles);
-AxeData=get(gca,'UserData');
-[erread,message]=fileattrib(filename);
-if ~isempty(message) && ~isequal(message.UserWrite,1)
-     msgbox_view_field('ERROR',['no writting access to ' filename])
-     return
-end
-test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
-test_civ1=isequal(get(handles.civ1,'BackgroundColor'),[1 1 0]);
-if ~test_civ2 && ~test_civ1
-    msgbox_view_field('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
-end 
-if test_civ2
-    nbname='nb_vectors2';
-   flagname='vec2_FixFlag';
-   attrname='fix2';
-end
-if test_civ1
-    nbname='nb_vectors';
-   flagname='vec_FixFlag';
-   attrname='fix';
-end
-%write fix flags in the netcdf file
-hhh=which('netcdf.open');% look for built-in matlab netcdf library
-if ~isequal(hhh,'')% case of new builtin Matlab netcdf library
-    nc=netcdf.open(filename,'NC_WRITE'); 
-    netcdf.reDef(nc)
-    netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),attrname,1)
-    dimid = netcdf.inqDimID(nc,nbname); 
-    try
-        varid = netcdf.inqVarID(nc,flagname);% look for already existing fixflag variable
-    catch
-        varid=netcdf.defVar(nc,flagname,'double',dimid);%create fixflag variable if it does not exist
-    end
-    netcdf.endDef(nc)
-    netcdf.putVar(nc,varid,AxeData.FF);
-    netcdf.close(nc)  
-else %old netcdf library
-    netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
-end
-
-function netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
-nc=netcdf(filename,'write'); %open netcdf file
-result=redef(nc);
-eval(['nc.' attrname '=1;']);
-theDim=nc(nbname) ;% get the number of velocity vectors
-nb_vectors=size(theDim);
-var_FixFlag=ncvar(flagname,nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag
-var_FixFlag(1:nb_vectors)=AxeData.FF;% 
-fin=close(nc);
+function CheckZoom_Callback(hObject, eventdata, handles)
+if (get(handles.CheckZoom,'Value') == 1); 
+    set(handles.CheckZoom,'BackgroundColor',[1 1 0])
+    set(handles.CheckFixLimits,'Value',1)% propose by default fixed limits for the plotting axes
+    set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
+else
+    set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7])
+end
+
+% %-------------------------------------------------------------------
+% %----Executes on button press in 'record': records the current flags of manual correction.
+% %-------------------------------------------------------------------
+% function record_Callback(hObject, eventdata, handles)
+% % [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles);
+% filename=read_file_boxes(handles);
+% AxeData=get(gca,'UserData');
+% [erread,message]=fileattrib(filename);
+% if ~isempty(message) && ~isequal(message.UserWrite,1)
+%      msgbox_view_field('ERROR',['no writting access to ' filename])
+%      return
+% end
+% test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
+% test_civ1=isequal(get(handles.civ1,'BackgroundColor'),[1 1 0]);
+% if ~test_civ2 && ~test_civ1
+%     msgbox_view_field('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
+% end 
+% if test_civ2
+%     nbname='nb_vectors2';
+%    flagname='vec2_FixFlag';
+%    attrname='fix2';
+% end
+% if test_civ1
+%     nbname='nb_vectors';
+%    flagname='vec_FixFlag';
+%    attrname='fix';
+% end
+% %write fix flags in the netcdf file
+% hhh=which('netcdf.open');% look for built-in matlab netcdf library
+% if ~isequal(hhh,'')% case of new builtin Matlab netcdf library
+%     nc=netcdf.open(filename,'NC_WRITE'); 
+%     netcdf.reDef(nc)
+%     netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),attrname,1)
+%     dimid = netcdf.inqDimID(nc,nbname); 
+%     try
+%         varid = netcdf.inqVarID(nc,flagname);% look for already existing fixflag variable
+%     catch
+%         varid=netcdf.defVar(nc,flagname,'double',dimid);%create fixflag variable if it does not exist
+%     end
+%     netcdf.endDef(nc)
+%     netcdf.putVar(nc,varid,AxeData.FF);
+%     netcdf.close(nc)  
+% else %old netcdf library
+%     netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
+% end
+% 
+% function netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
+% nc=netcdf(filename,'write'); %open netcdf file
+% result=redef(nc);
+% eval(['nc.' attrname '=1;']);
+% theDim=nc(nbname) ;% get the number of velocity vectors
+% nb_vectors=size(theDim);
+% var_FixFlag=ncvar(flagname,nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag
+% var_FixFlag(1:nb_vectors)=AxeData.FF;% 
+% fin=close(nc);
 
 
@@ -500,22 +507,4 @@
 set_vec_col_bar(handles)
 update_plot(handles)
-%------------------------------------------------------------
-%update the slider values after displaying vectors
-%--------------------------------------------------------
-% function slider_update(handles,auto,minC,colcode1,colcode2,maxC)
-% set(handles.slider1,'Min',minC) 
-% set(handles.slider1,'Max',maxC)
-% set(handles.slider2,'Min',minC) 
-% set(handles.slider2,'Max',maxC)
-% set(handles.min_C_title_vec,'String',num2str(minC))
-% set(handles.max_vec,'String',num2str(maxC))
-% if auto
-%         set(handles.colcode1,'String',num2str(colcode1,3))%update display
-%         set(handles.colcode2,'String',num2str(colcode2,3))
-% end
-% set(handles.slider1,'Value',colcode1)%update slider with constant display
-% set(handles.slider2,'Value',colcode2)
-% set_vec_col_bar(handles)
-
 
 %-------------------------------------------------------
@@ -719,17 +708,4 @@
 set(handles.vec_col_bar,'Cdata',A)
 
-% %------------------------------------------------------------------------
-% function PlotType=update_plot(handles)
-% %------------------------------------------------------------------------
-% haxes= handles.axes3;
-% 
-% %ProjField=get(haxes,'UserData');
-% ViewFieldData=get(handles.view_field,'UserData');
-% ProjField=ViewFieldData.axes3;
-% %ProjField=get(haxes,'UserData');
-% PlotParam=read_GUI(handles.view_field);
-% [PlotType,PlotParamOut]= plot_field(ProjField,haxes,PlotParam,1);
-% write_plot_param(handles,PlotParamOut); %update the auto plot parameters
-
 %-------------------------------------------------------------------
 function update_plot(handles)
@@ -768,6 +744,4 @@
 
 
-
-
 % --- Executes on selection change in ColorCode.
 function ColorCode_Callback(hObject, eventdata, handles)
