Index: /trunk/src/@xmltree/xmltree.m
===================================================================
--- /trunk/src/@xmltree/xmltree.m	(revision 1094)
+++ /trunk/src/@xmltree/xmltree.m	(revision 1095)
@@ -38,21 +38,25 @@
             % Input argument is an XML string
             if (~exist(varargin{1},'file') && ...
-                ~isempty(xml_findstr(varargin{1},'<',1,1)))
+                    ~isempty(xml_findstr(varargin{1},'<',1,1)))
                 tree.tree = xml_parser(varargin{1});
                 tree.filename = '';
-            % Input argument is an XML filename
+                % Input argument is an XML filename
             else
-                fid = fopen(varargin{1},'rt');
-                if (fid == -1) 
-                    error(['[XMLTree] Cannot open ' varargin{1}]);
+                if isempty(regexp(varargin{1},'^http://'))%ordinary file (not OpenDAP)
+                    fid = fopen(varargin{1},'rt');
+                    if (fid == -1)
+                        error(['[XMLTree] Cannot open ' varargin{1}]);
+                    end
+                    xmlstr = fread(fid,'*char')';
+                    %xmlstr = fscanf(fid,'%c');
+                    fclose(fid);
+                else
+                    xmlstr=webread(varargin{1});%OpenDAP case
                 end
-                xmlstr = fread(fid,'*char')';
-                %xmlstr = fscanf(fid,'%c');
-                fclose(fid);
                 tree.tree = xml_parser(xmlstr);
-                tree.filename = varargin{1};
+                tree.filename = varargin{1};             
             end
             tree = class(tree,'xmltree');
-        else 
+        else
             error('[XMLTree] Bad input argument');
         end
Index: /trunk/src/find_field_bounds.m
===================================================================
--- /trunk/src/find_field_bounds.m	(revision 1094)
+++ /trunk/src/find_field_bounds.m	(revision 1095)
@@ -119,7 +119,7 @@
             FieldOut.ProjModeRequest='interp_tps';
         end
-        if strcmp(CellInfo{imax(ind)}.ProjModeRequest,'interp_lin')&& ~strcmp(FieldOut.ProjModeRequest,'interp_tps')
-            FieldOut.ProjModeRequest='interp_lin';
-        end
+%         if strcmp(CellInfo{imax(ind)}.ProjModeRequest,'interp_lin')&& ~strcmp(FieldOut.ProjModeRequest,'interp_tps')
+%             FieldOut.ProjModeRequest='interp_lin';
+%         end
     end
 end
Index: /trunk/src/find_field_cells.m
===================================================================
--- /trunk/src/find_field_cells.m	(revision 1094)
+++ /trunk/src/find_field_cells.m	(revision 1095)
@@ -149,6 +149,4 @@
 
 %% initate cells around each scalar field with different coordinates
-% index_remove=[];
-% index_coord_x=zeros(size(ind_coord_x));
 cell_counter=0;
 DimCell={};
Index: /trunk/src/get_field.m
===================================================================
--- /trunk/src/get_field.m	(revision 1094)
+++ /trunk/src/get_field.m	(revision 1095)
@@ -79,5 +79,10 @@
 if ischar(filename) % input file name
     set(handles.inputfile,'String',filename)% fill the input file name
+    if ~isempty(regexp(filename,'.mat$'))%case of .mat file
+        Field=mat2struct(filename);
+        errormsg='';
+    else
     [Field,tild,tild,errormsg]=nc2struct(filename,[]);% reads the  field structure, without the variables
+    end
 else
     msgbox_uvmat('ERROR','get_field requires a file name as input')% display error message for input file reading
@@ -405,10 +410,4 @@
     case '1D plot'
         set(handles.Coordinates,'Visible','on')
-        %set(handles.PanelOrdinate,'Visible','on')
-        %pos=get(handles.PanelOrdinate,'Position');
-%         pos(1)=2;
-%         pos_coord=get(handles.Coordinates,'Position');
-%         pos(2)=pos_coord(2)-pos(4)-2;
-        %set(handles.PanelOrdinate,'Position',pos)
         set(handles.PanelScalar,'Visible','off')
         set(handles.PanelVectors,'Visible','off')
@@ -419,10 +418,7 @@
         set(handles.Z_title,'Visible','off')
         set(handles.Coord_x,'String',Field.Display.ListVarName')
-        Coord_x_Callback(hObject, VarName, handles) 
-        %set(handles.Coord_y,'String',Field.Display.ListVarName')
-        %Coord_x_Callback(hObject, VarName, handles)       
+        Coord_x_Callback(hObject, VarName, handles)     
     case {'scalar'}
         set(handles.Coordinates,'Visible','on')
-        %set(handles.PanelOrdinate,'Visible','off')
         set(handles.PanelScalar,'Visible','on')
         set(handles.PanelVectors,'Visible','off')
@@ -469,4 +465,5 @@
         set(handles.Coord_y,'Visible','on')
         set(handles.Y_title,'Visible','on')
+        set(handles.Coord_x,'Visible','on')
         %default vector selection
         vector_x_value=get(handles.vector_x,'UserData');
@@ -770,4 +767,5 @@
 update_field(handles,VarName)
 end
+
 %------------------------------------------------------------------------
 % --- Executes on selection change in vector_x or vector_y
@@ -803,5 +801,5 @@
     var_coord=find(test_coord);% % list of variable indices elligible as structured coordinates
     var_component(var_component==vector_x_index|var_component==vector_y_index)=[];
-    var_coord(var_coord==vector_x_index|var_coord==vector_y_index)=[];% remove vector components form te possible list of coordinates
+    var_coord(var_coord==vector_x_index|var_coord==vector_y_index)=[];% remove vector components from the possible list of coordinates
     ListCoord=Field.Display.ListVarName([var_coord var_component]);
     
@@ -844,6 +842,6 @@
             coord_val=[1 2 3];
         end
-        set(handles.Coord_x,'Value',coord_val(end))
-        set(handles.Coord_y,'Value',coord_val(end-1))
+        set(handles.Coord_x,'Value',min(coord_val(end),numel(ListCoord)))
+        set(handles.Coord_y,'Value',min(coord_val(end-1),numel(ListCoord)))
         if numel(coord_val)>=3
             set(handles.Coord_z,'Value',coord_val(end-2))
@@ -887,5 +885,5 @@
 %------------------------------------------------------------------------
 function Coord_x_Callback(hObject, DimCell, handles)
-DimCell
+
 index=get(handles.Coord_x,'Value');
 string=get(handles.Coord_x,'String');
Index: /trunk/src/mat2struct.m
===================================================================
--- /trunk/src/mat2struct.m	(revision 1095)
+++ /trunk/src/mat2struct.m	(revision 1095)
@@ -0,0 +1,39 @@
+%'mat2struct': read a matlab file .mat as a structure similar to the output
+%of nc2struct
+%----------------------------------------------------------------------
+function Field=mat2struct(filename,ListFieldName)
+
+Field=load(filename);%case of .mat data file
+if ~exist('ListFieldName','var')
+    ListFieldName=fieldnames(Field);
+end
+ivar=0;
+Field.DimValue=[];
+Field.ListGlobalAttribute={};
+Field.ListVarName={};
+ndim=0;
+for ilist=1:numel(ListFieldName)
+    if isnumeric(Field.(ListFieldName{ilist})) && numel(Field.(ListFieldName{ilist}))>=2
+        ivar=ivar+1;
+        Field.ListVarName=[Field.ListVarName ListFieldName{ilist}];
+        ndim_var=0;
+        for idim=1:ndims(Field.(ListFieldName{ilist}))
+            sizevar=size(Field.(ListFieldName{ilist}),idim);
+            if sizevar>1% avoid singleton dimensions
+                ndim_var=ndim_var+1;
+                prevdim_index=find(Field.DimValue==sizevar);%look for the same value of dimension
+                if isempty(prevdim_index)% new dimension detected
+                    ndim=ndim+1;
+                    Field.DimValue(ndim)=sizevar;
+                    Field.ListDimName{ndim}=num2str(sizevar);
+                    Field.VarDimName{ivar}{ndim_var}=Field.ListDimName{ndim};
+                else
+                    Field.VarDimName{ivar}{ndim_var}=Field.ListDimName{prevdim_index};
+                end
+            end
+        end
+        Field.VarType(ivar)=5;%for double variable
+    else
+        Field.ListGlobalAttribute=[Field.ListGlobalAttribute ListFieldName{ilist}];
+    end
+end
Index: /trunk/src/nc2struct.m
===================================================================
--- /trunk/src/nc2struct.m	(revision 1094)
+++ /trunk/src/nc2struct.m	(revision 1095)
@@ -1,4 +1,5 @@
 
 %'nc2struct': transform a NetCDF file in a corresponding matlab structure
+% or directly read the a matlab data file .mat (calling the fct mat2struct.m)
 % it reads all the global attributes and all variables, or a selected list.
 % The corresponding dimensions and variable attributes are then extracted
@@ -60,245 +61,248 @@
     varargin{1}='*';
 end
-hhh=which('netcdf.open');% look for built-in matlab NetCDF library
-
-if ~isempty(hhh)
-    %% default output
-    Data=[];%default
-    var_detect=[];%default
-    ichoice=[];%default
-
-    %% open the NetCDF file for reading
-    if ischar(nc)
-        if exist(nc,'file')
+
+%% default output
+Data=[];%default
+var_detect=[];%default
+ichoice=[];%default
+
+%% open the NetCDF (or .mat) file for reading
+if ischar(nc)
+    testfile=1;
+    if exist(nc,'file')
+        if ~isempty(regexp(nc,'.mat$'))
+            Data=mat2struct(nc,varargin{1});
+            return
+        else
             try
                 nc=netcdf.open(nc,'NC_NOWRITE');
-                testfile=1;
             catch ME
                 errormsg=['ERROR opening ' nc ': ' ME.message];
                 return
             end
+        end
+    else %case of OpenDAP files
+        if regexp(nc,'^http://')
+            try
+                nc=netcdf.open(nc,'NC_NOWRITE');
+            catch ME
+                errormsg=['ERROR opening ' nc ': ' ME.message];
+                return
+            end
         else
-            if regexp(nc,'^http://')
-                nc=netcdf.open(nc,'NC_NOWRITE');
-                testfile=1;
-            else
             errormsg=['ERROR:file ' nc ' does not exist'];
             return
-            end
-        end
+        end
+    end
+else
+    testfile=0;
+end
+
+%% short reading option for global attributes only, if the first argument is 'ListGlobalAttribute'
+if isequal(varargin{1},'ListGlobalAttribute')
+    for ilist=2:numel(varargin)
+        valuestr=[];%default
+        try
+            valuestr = netcdf.getAtt(nc,netcdf.getConstant('NC_GLOBAL'),varargin{ilist});
+        catch ME
+        end
+        eval(['Data.' varargin{ilist} '=valuestr;'])
+    end
+    netcdf.close(nc)
+    return
+end
+
+%% time variable or dimension
+input_index=1;
+CheckTimeVar=0;
+TimeVarName='';
+if isequal(varargin{1},'TimeVarName')
+    TimeVarName=varargin{2};
+    CheckTimeVar=1;
+    TimeIndex=varargin{3};
+    input_index=4;% list of variables to read is at fourth argument
+elseif isequal(varargin{1},'TimeDimName')
+    TimeDimName=varargin{2};
+    TimeIndex=varargin{3};
+    input_index=4;
+end
+
+%% full reading: get the nbre of dimensions, variables, global attributes
+ListVarName=varargin{input_index};
+[ndims,nvars,ngatts]=netcdf.inq(nc);%nbre of dimensions, variables, global attributes, in the NetCDF file
+
+%%  -------- read all global attributes (constants)-----------
+Data.ListGlobalAttribute={};%default
+att_key=cell(1,ngatts);%default
+for iatt=1:ngatts
+    keystr= netcdf.inqAttName(nc,netcdf.getConstant('NC_GLOBAL'),iatt-1);
+    valuestr = netcdf.getAtt(nc,netcdf.getConstant('NC_GLOBAL'),keystr);
+    keystr=regexprep(keystr,{'\','/','\.','-',' '},{'','','','',''});%remove  '\','.' or '-' if exists
+    if strcmp(keystr(1),'_')
+        keystr(1)=[];
+    end
+    try
+        if ischar(valuestr) %& length(valuestr)<200 & double(valuestr)<=122 & double(valuestr)>=48 %usual characters
+            eval(['Data.' keystr '=''' valuestr ''';'])
+        elseif isnumeric(valuestr)
+            eval(['Data.' keystr '=valuestr;'])
+        else
+            eval(['Data.' keystr '='';'])
+        end
+        att_key{iatt}=keystr;
+    catch ME
+        att_key{iatt}=['attr_' num2str(iatt)];
+        Data.(att_key{iatt})=[];
+    end
+end
+Data.ListGlobalAttribute=att_key;
+
+%%  -------- read dimension names-----------
+ListDimNameNetcdf=cell(1,ndims);
+dim_value=zeros(1,ndims);
+for idim=1:ndims %loop on the dimensions of the NetCDF file
+    [ListDimNameNetcdf{idim},dim_value(idim)] = netcdf.inqDim(nc,idim-1);%get name and value of each dimension
+end
+if ~isempty(ListDimNameNetcdf)
+    flag_used=zeros(1,ndims);%initialize the flag indicating the selected dimensions in the list (0=unused)
+end
+if isequal(varargin{1},'TimeDimName')% time dimension introduced
+    TimeDimIndex=find(strcmp(TimeDimName,ListDimNameNetcdf));
+    if isempty(TimeDimIndex)
+        errormsg=['requested time dimension ' varargin{2} ' not found'];
+        return
+    end
+    if dim_value(TimeDimIndex)<varargin{3}
+        errormsg=['requested time index ' num2str(varargin{3}) ' exceeds matrix dimension'];
+        return
+    end
+end
+
+%%  -------- read names of variables -----------
+ListVarNameNetcdf=cell(1,nvars); %default
+dimids=cell(1,nvars);
+nbatt=zeros(1,nvars);
+for ncvar=1:nvars %loop on the variables of the NetCDF file
+    %get name, type, dimensions and attribute numbers of each variable
+    [ListVarNameNetcdf{ncvar},xtype(ncvar),dimids{ncvar},nbatt(ncvar)] = netcdf.inqVar(nc,ncvar-1);
+end
+%     testmulti=0;
+if isequal(ListVarName,'*')||isempty(ListVarName)
+    var_index=1:nvars; %all the variables are selected in the NetCDF file
+    Data.ListVarName=ListVarNameNetcdf;
+else   %select input variables, if requested by the input ListVarName
+    check_keep=ones(1,size(ListVarName,2));
+    for ivar=1:size(ListVarName,2) % check redondancy of variable names
+        if ~isempty(find(strcmp(ListVarName{1,ivar},ListVarName(1:ivar-1)), 1))
+            check_keep(ivar)=0;% the variable #ivar is already in the list
+        end
+    end
+    ListVarName=ListVarName(:,logical(check_keep));
+    if size(ListVarName,1)>1 %multiple choice of variable ranked by order of priority
+        for iline=1:size(ListVarName,1)
+            search_index=find(strcmp(ListVarName{iline,1},ListVarNameNetcdf),1);%look for the first variable name in the list of NetCDF variables
+            if ~isempty(search_index)
+                break % go to the next line
+            end
+        end
+        ichoice=iline-1;%selected line number in the list of input names of variables
     else
-        testfile=0;
-    end
-
-    %% short reading option for global attributes only, if the first argument is 'ListGlobalAttribute'
-    if isequal(varargin{1},'ListGlobalAttribute')
-        for ilist=2:numel(varargin)
-            valuestr=[];%default
-            try
-                valuestr = netcdf.getAtt(nc,netcdf.getConstant('NC_GLOBAL'),varargin{ilist});
-            catch ME
-            end
-            eval(['Data.' varargin{ilist} '=valuestr;'])
-        end
-        netcdf.close(nc)
-        return
-    end
-
-    %% time variable or dimension
-    input_index=1;
-    CheckTimeVar=0;
-    TimeVarName='';
-    if isequal(varargin{1},'TimeVarName')
-        TimeVarName=varargin{2};
-        CheckTimeVar=1;
-        TimeIndex=varargin{3};
-        input_index=4;% list of variables to read is at fourth argument
-    elseif isequal(varargin{1},'TimeDimName')
-        TimeDimName=varargin{2};
-        TimeIndex=varargin{3};
-        input_index=4;
-    end
-
-    %% full reading: get the nbre of dimensions, variables, global attributes
-    ListVarName=varargin{input_index};
-    [ndims,nvars,ngatts]=netcdf.inq(nc);%nbre of dimensions, variables, global attributes, in the NetCDF file
-
-    %%  -------- read all global attributes (constants)-----------
-    Data.ListGlobalAttribute={};%default
-    att_key=cell(1,ngatts);%default
-    for iatt=1:ngatts
-        keystr= netcdf.inqAttName(nc,netcdf.getConstant('NC_GLOBAL'),iatt-1);
-        valuestr = netcdf.getAtt(nc,netcdf.getConstant('NC_GLOBAL'),keystr);
-        keystr=regexprep(keystr,{'\','/','\.','-',' '},{'','','','',''});%remove  '\','.' or '-' if exists
-        if strcmp(keystr(1),'_')
-            keystr(1)=[];
+        iline=1;
+    end
+    %ListVarName=ListVarName(iline,:);% select the appropriate option for input variable (lin ein the input name matrix)
+    if CheckTimeVar
+        TimeVarIndex=find(strcmp(TimeVarName,ListVarNameNetcdf),1); %look for the index of the time variable in the netcdf list
+        if isempty(TimeVarIndex)
+            errormsg='requested variable for time is missing';
+            return
+        end
+        TimeDimIndex=dimids{TimeVarIndex}(1)+1;
+        ListVarName=[ListVarName {TimeVarName}];
+    end
+    var_index=zeros(1,size(ListVarName,2));%default list of variable indices
+    for ivar=1:size(ListVarName,2)
+        search_index=find(strcmp(ListVarName{iline,ivar},ListVarNameNetcdf),1);%look for the variable name in the list of NetCDF file
+        if ~isempty(search_index)
+            var_index(ivar)=search_index;%index of the netcdf list corresponding to the input list index ivar
+        end
+    end
+    var_detect=(var_index~=0);%=1 for detected variables
+    list_index=find(var_index);% indices in the input list corresponding to a detected variable
+    var_index=var_index(list_index);% NetCDF variable indices corresponding to the output list of read variable
+    Data.ListVarName=ListVarName(1,list_index);%the first line of ListVarName sets the output names of the variables
+end
+
+%% get the dimensions and attributes associated to  variables
+var_dim=cell(size(var_index));% initiate list of dimensions for variables
+for ivar=1:length(var_index)
+    var_dim{ivar}=dimids{var_index(ivar)}+1; %netcdf dimension indices used by the variable #ivar
+    Data.VarDimName{ivar}=ListDimNameNetcdf(var_dim{ivar});
+    flag_used(var_dim{ivar})=ones(size(var_dim{ivar}));%flag_used =1 for the indices of used dimensions
+    for iatt=1:nbatt(var_index(ivar))
+        attname = netcdf.inqAttName(nc,var_index(ivar)-1,iatt-1);
+        valuestr= netcdf.getAtt(nc,var_index(ivar)-1,attname);
+        attname=regexprep(attname,{'\','/','\.','-',' '},{'','','','',''});%remove  '\','.' or '-' if exists
+        if strcmp(attname(1),'_')
+            attname(1)=[];
         end
         try
-            if ischar(valuestr) %& length(valuestr)<200 & double(valuestr)<=122 & double(valuestr)>=48 %usual characters
-                eval(['Data.' keystr '=''' valuestr ''';'])
-            elseif isnumeric(valuestr)
-                eval(['Data.' keystr '=valuestr;'])
-            else
-                eval(['Data.' keystr '='';'])
-            end
-            att_key{iatt}=keystr;
+            if ~isempty(valuestr)
+                Data.VarAttribute{ivar}.(attname)=valuestr;
+            end
         catch ME
-            att_key{iatt}=['attr_' num2str(iatt)];
-            Data.(att_key{iatt})=[];
-        end
-    end
-    Data.ListGlobalAttribute=att_key;
-
-    %%  -------- read dimension names-----------
-    ListDimNameNetcdf=cell(1,ndims);
-    dim_value=zeros(1,ndims);
-    for idim=1:ndims %loop on the dimensions of the NetCDF file
-        [ListDimNameNetcdf{idim},dim_value(idim)] = netcdf.inqDim(nc,idim-1);%get name and value of each dimension
-    end
-    if ~isempty(ListDimNameNetcdf)
-        flag_used=zeros(1,ndims);%initialize the flag indicating the selected dimensions in the list (0=unused)
-    end
-    if isequal(varargin{1},'TimeDimName')% time dimension introduced
-        TimeDimIndex=find(strcmp(TimeDimName,ListDimNameNetcdf));
-        if isempty(TimeDimIndex)
-            errormsg=['requested time dimension ' varargin{2} ' not found'];
-            return
-        end
-        if dim_value(TimeDimIndex)<varargin{3}
-           errormsg=['requested time index ' num2str(varargin{3}) ' exceeds matrix dimension'];
-            return
-        end
-    end
-
-    %%  -------- read names of variables -----------
-    ListVarNameNetcdf=cell(1,nvars); %default
-    dimids=cell(1,nvars);
-    nbatt=zeros(1,nvars);
-    for ncvar=1:nvars %loop on the variables of the NetCDF file
-        %get name, type, dimensions and attribute numbers of each variable
-        [ListVarNameNetcdf{ncvar},xtype(ncvar),dimids{ncvar},nbatt(ncvar)] = netcdf.inqVar(nc,ncvar-1);
-    end
-%     testmulti=0;
-    if isequal(ListVarName,'*')||isempty(ListVarName)
-        var_index=1:nvars; %all the variables are selected in the NetCDF file
-        Data.ListVarName=ListVarNameNetcdf;
-    else   %select input variables, if requested by the input ListVarName
-        check_keep=ones(1,size(ListVarName,2));
-        for ivar=1:size(ListVarName,2) % check redondancy of variable names
-            if ~isempty(find(strcmp(ListVarName{1,ivar},ListVarName(1:ivar-1)), 1))
-                check_keep(ivar)=0;% the variable #ivar is already in the list
-            end
-        end
-        ListVarName=ListVarName(:,logical(check_keep));
-        if size(ListVarName,1)>1 %multiple choice of variable ranked by order of priority
-            for iline=1:size(ListVarName,1)
-                search_index=find(strcmp(ListVarName{iline,1},ListVarNameNetcdf),1);%look for the first variable name in the list of NetCDF variables
-                if ~isempty(search_index)
-                    break % go to the next line
+            display(attname)
+            display(valuestr)
+            display(ME.message)
+            Data.VarAttribute{ivar}.(['atrr_' num2str(iatt)])='not read';
+        end
+    end
+end
+
+%% select the dimensions used for the set of input variables
+if ~isempty(var_index)
+    dim_index=find(flag_used);%list of netcdf dimensions indices corresponding to used dimensions
+    Data.ListDimName=ListDimNameNetcdf(dim_index);
+    Data.DimValue=dim_value(dim_index);
+    if input_index==4% if a dimension is selected as time
+        Data.DimValue(TimeDimIndex)=numel(TimeIndex);
+    end
+end
+
+%% get the values of the input variables
+if  ~isempty(ListVarName)
+    for ivar=1:length(var_index)
+        VarName=Data.ListVarName{ivar};
+        VarName=regexprep(VarName,'-','_'); %suppress '-' if it exists in the NetCDF variable name (leads to errors in matlab)
+        %             CheckSub=0;
+        if input_index==4% if a dimension is selected as time
+            ind_vec=zeros(1,numel(var_dim{ivar}));% vector with zeros corresponding to al the dimensions of the variable VarName
+            ind_size=dim_value(var_dim{ivar});% vector giving the size (for each dimension) of the variable VarName
+            index_time=find(var_dim{ivar}==TimeDimIndex);
+            if ~isempty(index_time)
+                if ind_size(index_time)<max(TimeIndex)
+                    errormsg=['requested index ' num2str(TimeIndex) ' exceeds matrix dimension'];
+                    return
                 end
-            end
-            ichoice=iline-1;%selected line number in the list of input names of variables
+                ind_vec(index_time)=TimeIndex-1;% selected index(or indices) to read
+                ind_size(index_time)=numel(TimeIndex);%length of the selected set of time indices
+                if numel(TimeIndex)==1 && ~strcmp(VarName,TimeVarName)
+                    Data.VarDimName{ivar}(index_time)=[];% for a single selected time remove the time in the list of dimensions (except for tTime itself)
+                end
+            end
+            Data.(VarName)=netcdf.getVar(nc,var_index(ivar)-1,ind_vec,ind_size); %read the variable data
+            Data.(VarName)=squeeze(Data.(VarName));%remove singeton dimension
         else
-            iline=1;
-        end
-        %ListVarName=ListVarName(iline,:);% select the appropriate option for input variable (lin ein the input name matrix)
-        if CheckTimeVar
-            TimeVarIndex=find(strcmp(TimeVarName,ListVarNameNetcdf),1); %look for the index of the time variable in the netcdf list
-            if isempty(TimeVarIndex)
-                errormsg='requested variable for time is missing';
-                return
-            end
-            TimeDimIndex=dimids{TimeVarIndex}(1)+1;
-            ListVarName=[ListVarName {TimeVarName}];
-        end
-        var_index=zeros(1,size(ListVarName,2));%default list of variable indices
-        for ivar=1:size(ListVarName,2)
-            search_index=find(strcmp(ListVarName{iline,ivar},ListVarNameNetcdf),1);%look for the variable name in the list of NetCDF file
-            if ~isempty(search_index)
-                var_index(ivar)=search_index;%index of the netcdf list corresponding to the input list index ivar
-            end
-        end
-        var_detect=(var_index~=0);%=1 for detected variables
-        list_index=find(var_index);% indices in the input list corresponding to a detected variable
-        var_index=var_index(list_index);% NetCDF variable indices corresponding to the output list of read variable
-        Data.ListVarName=ListVarName(1,list_index);%the first line of ListVarName sets the output names of the variables
-    end
-
-    %% get the dimensions and attributes associated to  variables
-    var_dim=cell(size(var_index));% initiate list of dimensions for variables
-    for ivar=1:length(var_index)
-        var_dim{ivar}=dimids{var_index(ivar)}+1; %netcdf dimension indices used by the variable #ivar
-        Data.VarDimName{ivar}=ListDimNameNetcdf(var_dim{ivar});
-        flag_used(var_dim{ivar})=ones(size(var_dim{ivar}));%flag_used =1 for the indices of used dimensions
-        for iatt=1:nbatt(var_index(ivar))
-            attname = netcdf.inqAttName(nc,var_index(ivar)-1,iatt-1);
-            valuestr= netcdf.getAtt(nc,var_index(ivar)-1,attname);
-            attname=regexprep(attname,{'\','/','\.','-',' '},{'','','','',''});%remove  '\','.' or '-' if exists
-            if strcmp(attname(1),'_')
-                attname(1)=[];
-            end
-            try
-                if ~isempty(valuestr)
-                    Data.VarAttribute{ivar}.(attname)=valuestr;
-                end
-            catch ME
-                display(attname)
-                display(valuestr)
-                display(ME.message)
-                Data.VarAttribute{ivar}.(['atrr_' num2str(iatt)])='not read';
-            end
-        end
-    end
-
-    %% select the dimensions used for the set of input variables
-    if ~isempty(var_index)
-        dim_index=find(flag_used);%list of netcdf dimensions indices corresponding to used dimensions
-        Data.ListDimName=ListDimNameNetcdf(dim_index);
-        Data.DimValue=dim_value(dim_index);
-        if input_index==4% if a dimension is selected as time
-            Data.DimValue(TimeDimIndex)=numel(TimeIndex);
-        end
-    end
-
-    %% get the values of the input variables
-    if  ~isempty(ListVarName)
-        for ivar=1:length(var_index)
-            VarName=Data.ListVarName{ivar};
-            VarName=regexprep(VarName,'-','_'); %suppress '-' if it exists in the NetCDF variable name (leads to errors in matlab)
-%             CheckSub=0;
-            if input_index==4% if a dimension is selected as time
-                ind_vec=zeros(1,numel(var_dim{ivar}));% vector with zeros corresponding to al the dimensions of the variable VarName
-                ind_size=dim_value(var_dim{ivar});% vector giving the size (for each dimension) of the variable VarName
-                index_time=find(var_dim{ivar}==TimeDimIndex);
-                if ~isempty(index_time)
-                    if ind_size(index_time)<max(TimeIndex)
-                        errormsg=['requested index ' num2str(TimeIndex) ' exceeds matrix dimension'];
-                        return
-                    end
-                    ind_vec(index_time)=TimeIndex-1;% selected index(or indices) to read
-                    ind_size(index_time)=numel(TimeIndex);%length of the selected set of time indices
-                    if numel(TimeIndex)==1 && ~strcmp(VarName,TimeVarName)
-                        Data.VarDimName{ivar}(index_time)=[];% for a single selected time remove the time in the list of dimensions (except for tTime itself)
-                    end
-                end
-                Data.(VarName)=netcdf.getVar(nc,var_index(ivar)-1,ind_vec,ind_size); %read the variable data
-                Data.(VarName)=squeeze(Data.(VarName));%remove singeton dimension
-            else
-                Data.(VarName)=netcdf.getVar(nc,var_index(ivar)-1); %read the whole variable data
-            end
-            if xtype(var_index(ivar))==5
-                Data.(VarName)=double(Data.(VarName)); %transform to double for single pecision
-            end
-        end
-    end
-    Data.VarType=xtype(var_index);
-
-    %%  -------- close fle-----------
-    if testfile==1
-        netcdf.close(nc)
-    end
-
-    %% old NetCDF library
-else
-    [Data,var_detect,ichoice]=nc2struct_toolbox(nc,varargin);
-end
+            Data.(VarName)=netcdf.getVar(nc,var_index(ivar)-1); %read the whole variable data
+        end
+        if xtype(var_index(ivar))==5
+            Data.(VarName)=double(Data.(VarName)); %transform to double for single pecision
+        end
+    end
+end
+Data.VarType=xtype(var_index);
+
+%%  -------- close fle-----------
+if testfile==1
+    netcdf.close(nc)
+end
+
Index: /trunk/src/plot_field.m
===================================================================
--- /trunk/src/plot_field.m	(revision 1094)
+++ /trunk/src/plot_field.m	(revision 1095)
@@ -1426,5 +1426,5 @@
     yi=rangy(1):dxy(1):rangy(2);
     A=griddata(vec_X,vec_Y,vec_A,xi,yi'); 
-    A=reshape(A,length(yi),length(xi));total
+    A=reshape(A,length(yi),length(xi));
 else
     x=vec_X(1:index(1));% the set of abscissa (obtained on the first line)
Index: /trunk/src/proj_field.m
===================================================================
--- /trunk/src/proj_field.m	(revision 1094)
+++ /trunk/src/proj_field.m	(revision 1095)
@@ -1126,4 +1126,5 @@
 ProjMode=regexprep(ProjMode,' ',ObjectData.ProjMode);
 icell_grid=[];% field cell index which defines the grid
+icell_scattered=[];% field cell index which defines fields with scattered coordinates
 if strcmp(ObjectData.ProjMode,'projection')
     %% case of a grid requested by the input field
@@ -1131,6 +1132,6 @@
         if isfield(CellInfo{icell},'ProjModeRequest')
             switch CellInfo{icell}.ProjModeRequest
-                case 'interp_lin'
-                    ProjMode{icell}='interp_lin';
+%                 case 'interp_lin'
+%                     ProjMode{icell}='interp_lin';
                 case 'interp_tps'
                     ProjMode{icell}='interp_tps';
@@ -1146,4 +1147,6 @@
             end
             check_grid(icell)=1;
+        elseif strcmp(CellInfo{icell}.CoordType,'scattered')
+            icell_scattered=icell;
         end
     end
@@ -1201,6 +1204,12 @@
     ProjData.VarAttribute{1}.Role='coord_y';
     ProjData.VarAttribute{2}.Role='coord_x';
+    if ~isempty(icell_grid)
             YAttribute=FieldData.VarAttribute{CellInfo{icell_grid}.CoordIndex(NbDim-1)};
         XAttribute=FieldData.VarAttribute{CellInfo{icell_grid}.CoordIndex(NbDim)};
+    elseif ~isempty(icell_scattered)
+        NbDim=NbDimArray(icell_scattered);
+        YAttribute=FieldData.VarAttribute{CellInfo{icell_scattered}.CoordIndex(NbDim-1)};
+        XAttribute=FieldData.VarAttribute{CellInfo{icell_scattered}.CoordIndex(NbDim)};
+    end
     if ~testangle 
         if isfield(YAttribute,'units')
Index: /trunk/src/read_field.m
===================================================================
--- /trunk/src/read_field.m	(revision 1094)
+++ /trunk/src/read_field.m	(revision 1095)
@@ -93,11 +93,8 @@
         if ~isempty(errormsg),errormsg=['read_civxdata / ' errormsg];return,end
         ParamOut.CivStage=Field.CivStage;
-    case 'netcdf'% general netcdf file (not recognized as civ)
+    case {'netcdf','mat'}% general netcdf file (not recognized as civ)
         ListVarName={};
         Role={};
         ProjModeRequest={};
-        %ListInputField={};
-        %checkU=0;
-        %checkV=0;
         % scan the list InputField
         Operator=cell(1,numel(InputField));
@@ -108,6 +105,4 @@
             if isempty(r)%  no operator used
                 ListVarName=[ListVarName InputField(ilist)];%append the variable name
-                %InputVar{ilist}=InputField(ilist);
-                %ListInputField=[ListInputField InputField(ilist)];
                 if check_colorvar(ilist)% case of field used for vector color
                     Role{numel(ListVarName)}='ancillary';% not projected with interpolation
@@ -129,8 +124,6 @@
                      Role=[Role {'vector_x'}];
                 end
-                %ListInputField=[ListInputField InputField(ilist)];
                 ListVarName=[ListVarName {r.VName}];% append the variable in the list if not previously listed
                 Role=[Role {'vector_y'}];
-                %ListInputField=[ListInputField InputField(ilist)];
                 Operator{numel(ListVarName)-1}=r.Operator;
                 Operator{numel(ListVarName)}='';           
@@ -238,7 +231,5 @@
             Field.VarDimName=[Field.VarDimName(1:NbCoord) VarDimName];
             Field.VarAttribute=[Field.VarAttribute(1:NbCoord) VarAttribute];
-        end
-    case 'mat'
-         Field=load(FileName);  
+        end  
     case 'video'
         if strcmp(class(ParamIn),'VideoReader')
Index: /trunk/src/read_xls.m
===================================================================
--- /trunk/src/read_xls.m	(revision 1094)
+++ /trunk/src/read_xls.m	(revision 1095)
@@ -13,5 +13,5 @@
 % Copyright 2008-2021, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France
 %   http://www.legi.grenoble-inp.fr
-%   Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr
+%   Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.frread_xls.m
 %
 %     This file is part of the toolbox UVMAT.
Index: /trunk/src/series.m
===================================================================
--- /trunk/src/series.m	(revision 1094)
+++ /trunk/src/series.m	(revision 1095)
@@ -3423,6 +3423,9 @@
 
 %% fill the GUI series with the content of the xml file
-Param=xml2struct(filexml); % read the input xml file as a Matlab structure
-
+[Param,RootTag,errormsg]=xml2struct(filexml); % read the input xml file as a Matlab structure
+if ~isempty(errormsg)
+    msgbox_uvmat('ERROR',errormsg);
+    return
+end
 % ask to stop current Action if button RUN is in action (another process is already running)
 if isequal(get(handles.RUN,'Value'),1)
Index: /trunk/src/series/civ_series.m
===================================================================
--- /trunk/src/series/civ_series.m	(revision 1094)
+++ /trunk/src/series/civ_series.m	(revision 1095)
@@ -366,7 +366,8 @@
             end
             if strcmp(Param.ActionInput.ListCompareMode,'PIV')
-                ncfile_out=fullfile_uvmat(RootPath_A,OutputDir,RootFile_A,'.nc',NomTypeNc,i1_civ2,i2_civ2,j1_civ2,j2_civ2);
+                ncfile_out=fullfile_uvmat(OutputPath,OutputDir,RootFile_A,'.nc',NomTypeNc,i1_civ2,i2_civ2,j1_civ2,j2_civ2);
+%                 ncfile_out=fullfile_uvmat(RootPath_A,OutputDir,RootFile_A,'.nc',NomTypeNc,i1_civ2,i2_civ2,j1_civ2,j2_civ2);
             else % displacement
-                ncfile_out=fullfile_uvmat(RootPath_A,OutputDir,RootFile_A,'.nc',NomTypeNc,i2_civ2,[],j2_civ2);
+                ncfile_out=fullfile_uvmat(OutputPath,OutputDir,RootFile_A,'.nc',NomTypeNc,i2_civ2,[],j2_civ2);
             end
         end
Index: /trunk/src/series/sliding_average.m
===================================================================
--- /trunk/src/series/sliding_average.m	(revision 1094)
+++ /trunk/src/series/sliding_average.m	(revision 1095)
@@ -121,5 +121,5 @@
         return
     end
-    [FileInfo{iview},MovieObject{iview}]=get_file_info(filecell{iview,1});900
+    [FileInfo{iview},MovieObject{iview}]=get_file_info(filecell{iview,1});
     FileType{iview}=FileInfo{iview}.FileType;
     CheckImage{iview}=~isempty(find(strcmp(FileType{iview},ImageTypeOptions)));% =1 for images
@@ -137,5 +137,5 @@
 if size(time,1)>1
     diff_time=max(max(diff(time)));
-    if diff_time>0series
+    if diff_time>0
         msgbox_uvmat('WARNING',['times of series differ by (max) ' num2str(diff_time)])
     end   
@@ -185,5 +185,5 @@
 
 %% initialisation
-T=24.2; %main wave period
+T=24.4; %main wave period
 t0=3; % time for motion start (torus at its maximum x)
 NbPeriod=2; %number of periods for the sliding average
@@ -195,9 +195,9 @@
 DataOut.ListGlobalAttribute= {'Conventions','Time'};
 DataOut.Conventions='uvmat';
-DataOut.ListVarName={'coord_y','coord_x','Umean','Vmean','Ucos','Vcos','DUDXsin','DUDXcos','DUDYsin','DVDXsin','DVDXcos'...
+DataOut.ListVarName={'coord_y','coord_x','Umean','Vmean','Ucos','Vcos','Usin','Vsin','DUDXsin','DUDXcos','DUDYsin','DVDXsin','DVDXcos'...
     ,'DVDYsin','Ustokes','Vstokes'};
 DataOut.VarDimName={'coord_y','coord_x',{'coord_y','coord_x'},{'coord_y','coord_x'},{'coord_y','coord_x'},{'coord_y','coord_x'},...
     {'coord_y','coord_x'},{'coord_y','coord_x'},{'coord_y','coord_x'},{'coord_y','coord_x'},{'coord_y','coord_x'},...
-    {'coord_y','coord_x'},{'coord_y','coord_x'},{'coord_y','coord_x'}};
+    {'coord_y','coord_x'},{'coord_y','coord_x'},{'coord_y','coord_x'},{'coord_y','coord_x'},{'coord_y','coord_x'}};
 
 %%%%%%%%%%%%%%%% loop on field indices %%%%%%%%%%%%%%%%
@@ -237,4 +237,6 @@
         Ucos=zeros(NpTime,npy,npx);
         Vcos=zeros(NpTime,npy,npx);
+        Usin=zeros(NpTime,npy,npx);
+        Vsin=zeros(NpTime,npy,npx);
         DUDXcos=zeros(NpTime,npy,npx);
         DUDXsin=zeros(NpTime,npy,npx);
@@ -249,4 +251,6 @@
     Ucos=circshift(Ucos,[-1 0 0]); %shift U by ishift along the first index
     Vcos=circshift(Vcos,[-1 0 0]); %shift U by ishift along the first index
+    Usin=circshift(Usin,[-1 0 0]); %shift U by ishift along the first index
+    Vsin=circshift(Vsin,[-1 0 0]); %shift U by ishift along the first index
     DUDXcos=circshift(DUDXcos,[-1 0 0]);
     DUDXsin=circshift(DUDXsin,[-1 0 0]);
@@ -259,4 +263,6 @@
     Ucos(end,:,:)=Field.U*cos(omega*Time(index));
     Vcos(end,:,:)=Field.V*cos(omega*Time(index));
+    Usin(end,:,:)=Field.U*sin(omega*Time(index));
+    Vsin(end,:,:)=Field.V*sin(omega*Time(index));
     DUDXcos(end,:,:)=Field.DUDX*cos(omega*Time(index));
     DUDXsin(end,:,:)=Field.DUDX*sin(omega*Time(index));
@@ -269,6 +275,8 @@
     DataOut.Umean=(1/Uscale)*squeeze(nanmean(Umean,1));
     DataOut.Vmean=(1/Uscale)*squeeze(nanmean(Vmean,1));
-    DataOut.Ucos=2*squeeze(nanmean(Ucos,1));
-    DataOut.Vcos=2*squeeze(nanmean(Vcos,1));
+    DataOut.Ucos=2*(1/Uscale)*squeeze(nanmean(Ucos,1));
+    DataOut.Vcos=2*(1/Uscale)*squeeze(nanmean(Vcos,1));
+    DataOut.Usin=2*(1/Uscale)*squeeze(nanmean(Usin,1));
+    DataOut.Vsin=2*(1/Uscale)*squeeze(nanmean(Vsin,1));
     DataOut.DUDXcos=2*squeeze(nanmean(DUDXcos,1));
     DataOut.DUDXsin=2*squeeze(nanmean(DUDXsin,1));
Index: /trunk/src/series/turb_stat.m
===================================================================
--- /trunk/src/series/turb_stat.m	(revision 1094)
+++ /trunk/src/series/turb_stat.m	(revision 1095)
@@ -303,5 +303,5 @@
 
 %% open the result file with uvmat (in RUN mode)
-if checkrun
+if checkrun && isequal(Param.IndexRange.NbSlice,1)
     uvmat(OutputFile)% open the last result file with uvmat
 end
Index: /trunk/src/uigetfile_uvmat.m
===================================================================
--- /trunk/src/uigetfile_uvmat.m	(revision 1094)
+++ /trunk/src/uigetfile_uvmat.m	(revision 1095)
@@ -54,5 +54,5 @@
         elseif exist(InputName,'file')
             [InputDir,InputFileName,Ext]=fileparts(InputName);
-            if isempty(InputFileName)% if InputName is already the root
+            if isempty(InputFileName)% if InputName is alr2eady the root
                 InputFileName=InputDir;
                 if  ~isempty(strcmp (computer, {'PCWIN','PCWIN64'}))%case of Windows systems
@@ -308,5 +308,6 @@
         FullSelectName=[DirName '/' SelectName];
     end
-end
+end%     end
+% end
 if CheckSubDir%exist(FullSelectName,'dir')% a directory has been selected
     set(hObject,'BackgroundColor',[1 1 0])% paint list in yellow to indicate action
@@ -344,9 +345,5 @@
 index_dir=find(strcmp('isdir',fieldnames(ListStruct)));
 check_dir=cell2mat(ListCells(index_dir,:));% =1 for directories, =0 for files
-% for ilist=1:numel(check_dir)
-%     if check_dir(ilist)
 ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display
-%     end
-% end
 if exist('filter_ext','var') && ~strcmp(filter_ext,'*') &&~strcmp(filter_ext,'uigetdir')
     if strcmp(filter_ext,'image')
Index: /trunk/src/update_imadoc.m
===================================================================
--- /trunk/src/update_imadoc.m	(revision 1094)
+++ /trunk/src/update_imadoc.m	(revision 1095)
@@ -90,8 +90,8 @@
 
 %% save the output file
-t=struct2xml(Struct,t,uid_calib); 
+t=struct2xml(Struct,t,uid_calib);
 try
-save(t,outputfile);
+    save(t,outputfile);
 catch ME
-    errormsg=['error in update_imadoc' ME.message];
+    errormsg=['error in saving ' outputfile ': ' ME.message];
 end
Index: /trunk/src/uvmat.m
===================================================================
--- /trunk/src/uvmat.m	(revision 1094)
+++ /trunk/src/uvmat.m	(revision 1095)
@@ -2198,12 +2198,12 @@
         editxml(fileinput);
         return
-    case 'mat'% matlab data file
-        global Data_uvmat
-Data_uvmat.Field=load(fileinput);
-evalin('base','global Data_uvmat')%make CurData global in the workspace
-disp('Data_uvmat.Field=')
-evalin('base','Data_uvmat.Field') %display CurData in the workspace
-commandwindow; %brings the Matlab command window to the front
-return
+%     case 'mat'% matlab data file
+% %         global Data_uvmat
+% Data_uvmat.Field=load(fileinput);
+% evalin('base','global Data_uvmat')%make CurData global in the workspace
+% disp('Data_uvmat.Field=')
+% evalin('base','Data_uvmat.Field') %display CurData in the workspace
+% commandwindow; %brings the Matlab command window to the front
+% return
     otherwise
         set(handles_RootPath,'String',RootPath);
@@ -2278,5 +2278,4 @@
         
         %enable other menus
-%         set(handles.MenuOpenCampaign,'Enable','on')
         set(handles.MenuExport,'Enable','on')
         set(handles.MenuExportFigure,'Enable','on')
@@ -2355,5 +2354,5 @@
 if isfield(FileInfo,'FrameRate')% frame rate given in the file (case of video data)
     TimeUnit='s';
-    if isempty(j1_series); %frame index along i
+    if isempty(j1_series) %frame index along i
         XmlData.Time=zeros(FileInfo.NumberOfFrames+1,2);
         XmlData.Time(:,2)=(0:1/FileInfo.FrameRate:(FileInfo.NumberOfFrames)/FileInfo.FrameRate)';
@@ -2552,5 +2551,5 @@
         set(handles.Coord_x,'String','X');
         set(handles.Coord_y,'String','Y');
-    case 'netcdf'
+    case {'netcdf','mat'}
         set(handles_Fields,'Value',1)
         set(handles_Fields,'String',{'get_field...'})
@@ -3019,5 +3018,5 @@
         pause(1.02-get(handles.speed,'Value'))% wait for next image
 end
-if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj),
+if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj)
     UvData.aviobj=close(UvData.aviobj);
    set(handles.uvmat,'UserData',UvData);
@@ -3063,5 +3062,4 @@
 set(handles.MovieBackward,'BusyAction','Cancel')
 set(handles.MenuExportMovie,'BusyAction','Cancel')
-%set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command buttonback to red
 set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
 set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red
@@ -3073,8 +3071,8 @@
 errormsg='';%default
 %% check for movie pair status
-movie_status=get(handles.movie_pair,'Value');
-if movie_status
-    STOP_Callback(hObject, eventdata, handles)%interrupt movie pair if active
-end
+% movie_status=get(handles.movie_pair,'Value');
+% if movie_status
+%     STOP_Callback(hObject, eventdata, handles)%interrupt movie pair if active
+% end
 
 %% read the current input file name(s) and field indices
@@ -3090,10 +3088,10 @@
     j1=str2num(get(handles.j1,'String'));%case of indexed movie
 end
-if movie_status% we read the second index from the edit box
-    i2=str2num(get(handles.i2,'String'));%read the field indices (for movie, it is not given by the file name)
-    if strcmp(get(handles.j2,'Visible'),'on')
-    j2=str2num(get(handles.j2,'String'));%
-    end
-end
+% if movie_status% we read the second index from the edit box
+%     i2=str2num(get(handles.i2,'String'));%read the field indices (for movie, it is not given by the file name)
+%     if strcmp(get(handles.j2,'Visible'),'on')
+%     j2=str2num(get(handles.j2,'String'));%
+%     end
+% end
 sub_value= get(handles.SubField,'Value');
 if sub_value % a second input file has been entered
@@ -3113,5 +3111,5 @@
     set(handles.CheckFixPair,'Value',0)
 end
-CheckFixPair=get(handles.CheckFixPair,'Value')||(isempty(i2)&&isempty(j2));
+CheckFixPair=get(handles.CheckFixPair,'Value')||(isempty(i2)&& isempty(j2));
 
 % the pair i1-i2 or j1-j2 is imposed (check box CheckFixPair selected)
@@ -3132,6 +3130,6 @@
         end
     end
-
-% the pair i1-i2 or j1-j2 is free (check box CheckFixPair not selected): the list of existing indices recorded in UvData is used
+    
+    % the pair i1-i2 or j1-j2 is free (check box CheckFixPair not selected): the list of existing indices recorded in UvData is used
 else
     UvData=get(handles.uvmat,'UserData');
@@ -3154,5 +3152,4 @@
         end
     else % free increment
-       % runaction=get(gcbo,'tag');
         if strcmp(increment,'+')% if runplus or movie is activated
             step=1;
@@ -3203,5 +3200,5 @@
         j2=UvData.j2_series{1}(ref_indices(end));
     end
-
+    
     % case of a second file series
     if sub_value
@@ -3300,7 +3297,7 @@
     end
     if strcmp(NomType,'level')
-       indices=num2str(i1);
+        indices=num2str(i1);
     else
-    indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2);
+        indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2);
     end
     set(handles.FileIndex,'String',indices);
@@ -3309,11 +3306,6 @@
         set(handles.FileIndex_1,'String',indices_1);
     end
-    if isequal(movie_status,1)
-        set(handles.movie_pair,'Value',1)
-        movie_pair_Callback(hObject, eventdata, handles); %reactivate moviepair if it was activated
-    else
-        if isempty(i2), set(handles.i2,'String',''); end % suppress the second index display if not used
-        if isempty(j2), set(handles.j2,'String',''); end
-    end
+    if isempty(i2), set(handles.i2,'String',''); end % suppress the second index display if not used
+    if isempty(j2), set(handles.j2,'String',''); end
 end
 
@@ -3352,11 +3344,11 @@
         msgbox_uvmat('ERROR',errormsg);
     end
-    
-    %     set(hima,'CData',Field_b.A); %TODO: generalise to other kinds of fields
     pause(1.02-get(handles.speed,'Value'));% wait for next image
     errormsg=runpm(hObject,eventdata,handles,-increment);
-    
-    %     set(hima,'CData',Field_a.A);
+    if ~isempty(errormsg)
+        msgbox_uvmat('ERROR',errormsg);
+    end
     pause(1.02-get(handles.speed,'Value'));% wait for next image
+    get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue')
 end
 set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
@@ -3364,164 +3356,6 @@
 set(handles.Dt_txt,'String','')
 
-
-
-
 set(handles.runplus,'BackgroundColor',[1 0 0])%paint the command button back in red
 
-% 
-% set(handles.runmin,'BackgroundColor',[1 1 0])%paint the command button in yellow
-% drawnow
-% increment=-str2double(get(handles.num_IndexIncrement,'String')); %get the field increment d
-% if isnan(increment)% case of free increment: move to previous available field index
-%     increment='-';
-% end
-% errormsg=runpm(hObject,eventdata,handles,increment);
-% if ~isempty(errormsg)
-%     msgbox_uvmat('ERROR',errormsg);
-% end
-% set(handles.runmin,'BackgroundColor',[1 0 0])%paint the command button back in red
-% 
-% %% check the input file indexing:
-% [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);
-% NomType=get(handles.NomType,'String');
-% if ~isempty(find(regexp(NomType,'-')))
-%     msgbox_uvmat('ERROR','The movie pair requires file series with a single index on the first input line')
-%     return
-% end
-% filename=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];% build the input file name (first line)
-% 
-% set(handles.movie_pair,'BusyAction','queue')%
-% set(handles.CheckFixPair,'Value',1)% impose fixed pair (needed for function runpm)
-% set(handles.REFRESH,'BackgroundColor',[1 1 0])%paint the command button in yellow to indicate its activity
-% set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow to indicate its activity
-% drawnow
-% 
-% num_i1=str2num(get(handles.i1,'String'));
-% num_j1=stra2num(get(handles.j1,'String'));
-% num_i2=str2num(get(handles.i2,'String'));
-% num_j2=stra2num(get(handles.j2,'String'));
-% 
-% %% determine the name 'imaname_1' of the second file in the pair
-% imaname_1='';
-% if isempty(num_j2)% no second j index indicated
-%     if isempty(num_i2)
-%         if strcmp(get(handles.j2,'Visible'),'on') %if the j box is visible
-%             imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,num_i1,[],num_j1+1);
-%         end
-%         if exist(imaname_1,'file')
-%             num_j2=num_j1+1;% look by default for the next j index as the second file
-%             set(handles.j2,'String',num2stra(num_j2,NomType));
-%         else
-%             imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,num_i1+1,[],num_j1);
-%             if exist(imaname_1,'file')
-%                 num_i2=num_i1+1;
-%                 set(handles.i2,'String',num2str(num_i2));
-%             else
-%                 msgbox_uvmat('ERROR', 'a second image index i2 or j2 is needed to show the pair as a movie')
-%                 set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
-%                 set(handles.movie_pair,'Value',0)
-%                 return
-%             end
-%         end
-%     else
-%         num_j2=num_j1;%repeat the index i1 by default
-%     end
-% end
-% if isempty(num_i2)
-%     num_i2=num_i1;%repeat the index i1 by default
-% end
-% if isempty(num_j1)
-%     num_j1=1;
-% end
-% if isempty(num_j2)
-%     num_j2=num_j1;%repeat the index i1 by default
-% end
-% imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,num_i2,[],num_j2);
-% if strcmp(NomType,'*')
-%     num_frame=num_i2;
-% else
-%     num_frame=num_j2;
-% end
-% if ~exist(imaname_1,'file')
-%       msgbox_uvmat('ERROR',['second input open (-)  ' imaname_1 ' not found']);
-%       set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
-%        set(handles.movie_pair,'Value',0)
-%       return
-% end
-% 
-% %% display the first field in the pair (including possibly a background field from second line input filename_1)
-% filename_1='';%default
-% FileIndex_1='';
-% if get(handles.SubField,'Value')
-%     [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles);
-%     filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1];
-% end
-% [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(FileIndex_1);% get the indices of the second series from the string FileIndex_1
-% if isempty(j1_1)% case of movies, the index is not given by file index
-%     j1_1=num_j1;
-% end
-% 
-% errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1);
-% 
-% if isempty(errormsg)
-%     set(handles.REFRESH,'BackgroundColor',[1 0 0])% set button color to red, update successfull
-% else
-%      msgbox_uvmat('ERROR',errormsg);
-%      set(handles.REFRESH,'BackgroundColor',[1 0 1])% keep button color magenta, input not succesfull
-% end
-% UvData=get(handles.uvmat,'UserData');
-% Field_a=UvData.Field;% movie on the field defined by the second input line
-% 
-% %% display time interval for the image pair
-% if isfield(UvData,'XmlData')&&isfield(UvData.XmlData{1},'Time')...
-%         && size(UvData.XmlData{1}.Time,1)>=num_i2+1 && size(UvData.XmlData{1}.Time,2)>=num_j2+1
-%     dt=(UvData.XmlData{1}.Time(num_i2+1,num_j2+1)-UvData.XmlData{1}.Time(num_i1+1,num_j1+1));
-%     if  isfield(UvData,'TimeUnit')
-%         set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) '  m' UvData.TimeUnit] )
-%     else
-%         set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) '  10^(-3)'] )
-%     end
-% else
-%     set(handles.Dt_txt,'String','')
-% end
-% 
-% %% read the second field
-% if isempty(UvData.MovieObject)
-%     [Field_b,ParamOut,errormsg] = read_field(imaname_1,UvData.FileInfo{index}.FileType,[],num_frame);
-% else
-%     [Field_b,ParamOut,errormsg] = read_field(imaname_1,UvData.FileInfo{1}.FileType,UvData.MovieObject{1},num_frame);
-% end
-% if ~isempty(errormsg)
-%     msgbox_uvmat('ERROR',['Error in reading second image: ' errormsg])
-%     return
-% end
-% 
-% %% apply phys or other transform on the two input fields
-% transform=get(handles.TransformPath,'UserData');
-% if  ~isempty(transform)
-%     if isfield(UvData,'XmlData') && ~isempty(UvData.XmlData) %use geometry calib recorded from the ImaDoc xml file as first priority
-%         if nargin(transform)>=2
-%             Field_b=transform(Field_b,UvData.XmlData{1});
-%         else
-%             Field_b=transform(Field_b);
-%         end
-%     end
-% end
-% 
-% %% make movie until movie speed is set to 0 or STOP is activated
-% hima=findobj(handles.PlotAxes,'Tag','ima');% %handles.PlotAxes =main plotting window (A GENERALISER)
-% set(handles.STOP,'Visible','on')
-% set(handles.speed,'Visible','on')
-% set(handles.speed_txt,'Visible','on')
-% while get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue') % enable STOP command
-%     % read and plot the series of images in non erase mode
-%     set(hima,'CData',Field_b.A); %TODO: generalise to other kinds of fields
-%     pause(1.02-get(handles.speed,'Value'));% wait for next image
-%     set(hima,'CData',Field_a.A);
-%     pause(1.02-get(handles.speed,'Value'));% wait for next image
-% end
-% set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
-% set(handles.movie_pair,'Value',0)
-% set(handles.Dt_txt,'String','')
 
 %------------------------------------------------------------------------
@@ -3660,8 +3494,11 @@
 end
 switch UvData.FileInfo{1}.FieldType
-    case {'civdata','netcdf'}
+    case {'civdata','netcdf','mat'}
         list_fields=get(handles.FieldName,'String');% list menu fields
         FieldName= list_fields{get(handles.FieldName,'Value')}; % selected field
-        if ~strcmp(FieldName,'get_field...')
+        if strcmp(FieldName,'get_field...')
+            FieldName_Callback(hObject, eventdata, handles)
+            return
+        else
             if get(handles.FixVelType,'Value')
                 VelTypeList=get(handles.VelType,'String');
@@ -3697,5 +3534,4 @@
     end
     ParamIn.Coord_z=get(handles.Coord_z,'String');
-    %ParamIn.CheckCoordIndex=strcmp(get(handles.SwitchCoordIndex,'String'),'dim');
     TimeName=get(handles.TimeName,'String');
     r=regexp(TimeName,'^(?<type>(dim:)|(var:))','names');%look for 'var:' or 'dim:' at the beginning of time name
@@ -3768,5 +3604,5 @@
     end
     switch UvData.FileInfo{2}.FileType
-        case {'civx','civdata','netcdf','pivdata_fluidimage'}
+        case {'civx','civdata','netcdf','pivdata_fluidimage','mat'}
             list_fields=get(handles.FieldName_1,'String');% list menu fields
             FieldName_1= list_fields{get(handles.FieldName_1,'Value')}; % selected field
@@ -4170,5 +4006,5 @@
             break
         end
-        if UvData.Field.NbDim==3
+        if isfield(UvData.Field,'NbDim') && UvData.Field.NbDim==3
             UvData.ProjObject{iobj}.NbDim=3;%test for 3D objects
             if ~isfield(UvData.ProjObject{iobj},'RangeZ')
@@ -5356,5 +5192,5 @@
     prev_path=fullfile(fileparts(which('uvmat')),'transform_field');
 end
-if strcmp(transform_name,'more...');
+if strcmp(transform_name,'more...')
     transform_fct_chosen=uigetfile_uvmat('Pick the transform function',prev_path,'.m');
     if ~isempty(transform_fct_chosen)
@@ -5444,7 +5280,4 @@
 %% delete drawn objects if the output CooordUnit is different from the previous one
 if  ~strcmp(CoordUnit,CoordUnitPrev)
-%     for iobj=1:numel(UvData.ProjObject)
-%         delete_object(iobj)
-%     end
     set(handles.CheckFixLimits,'Value',0)
     hother=findobj('Tag','proj_object');%find all the proj objects
@@ -5834,5 +5667,5 @@
 AxeData=[];
 if isfield(UvData,'PlotAxes')
-AxeData=UvData.PlotAxes;% retrieve the current plotted data
+    AxeData=UvData.PlotAxes;% retrieve the current plotted data
 end
 PlotParam=read_GUI(handles.uvmat);
Index: /trunk/src/xml2struct.m
===================================================================
--- /trunk/src/xml2struct.m	(revision 1094)
+++ /trunk/src/xml2struct.m	(revision 1095)
@@ -29,5 +29,5 @@
 %     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 %     GNU General Public License (see LICENSE.txt) for more details.
-%=======================================================================
+%=======================================================================UVMAT-https	
 
 function [s,RootTag,errormsg]=xml2struct(filename,varargin)
