Changeset 895 for trunk/src/proj_field.m


Ignore:
Timestamp:
May 20, 2015, 11:21:25 AM (9 years ago)
Author:
sommeria
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/proj_field.m

    r890 r895  
    12751275                    [VarVal,ListVarName,VarAttribute,errormsg]=calc_field_interp([coord_X coord_Y],FieldData,CellInfo{icell}.FieldName,XI,YI);
    12761276                   
    1277                     % set to NaN interpolation points which are too far from any initial data (more than 2 CoordMaesh)
    1278                     F=scatteredInterpolant(coord_X, coord_Y,coord_X,'nearest');
    1279                     G=scatteredInterpolant(coord_X, coord_Y,coord_Y,'nearest');
     1277                    % set to NaN interpolation points which are too far from any initial data (more than 2 CoordMesh)
     1278                    if exist('scatteredInterpolant','file')%recent Matlab versions
     1279                        F=scatteredInterpolant(coord_X, coord_Y,coord_X,'nearest');
     1280                        G=scatteredInterpolant(coord_X, coord_Y,coord_Y,'nearest');
     1281                    else
     1282                        F=TriScatteredInterp([coord_X coord_Y],coord_X,'nearest');
     1283                        G=TriScatteredInterp([coord_X coord_Y],coord_Y,'nearest');
     1284                    end
    12801285                    Distx=F(XI,YI)-XI;% diff of x coordinates with the nearest measurement point
    12811286                    Disty=G(XI,YI)-YI;% diff of y coordinates with the nearest measurement point
     
    13191324                [DataOut,VarAttribute,errormsg]=calc_field_tps(Coord,NbCentres,SubRange,FieldVar,CellInfo{icell}.FieldName,cat(3,XI,YI));
    13201325               
    1321                 % set to NaN interpolation points which are too far from any initial data (more than 2 CoordMaesh)
    1322                 F=scatteredInterpolant(coord_X, coord_Y,coord_X,'nearest');
    1323                 G=scatteredInterpolant(coord_X, coord_Y,coord_Y,'nearest');
    1324                 Distx=F(XI,YI)-XI;% diff of x coordinates with the nearest measurement point
    1325                 Disty=G(XI,YI)-YI;% diff of y coordinates with the nearest measurement point
    1326                 Dist=Distx.*Distx+Disty.*Disty;
    1327                 for ivar=1:numel(VarVal)
    1328                     VarVal{ivar}(Dist>2*ProjData.CoordMesh)=NaN;% put to NaN interpolated positions too far from initial data
    1329                 end
     1326                % set to NaN interpolation points which are too far from any initial data (more than 2 CoordMesh)
     1327                    if exist('scatteredInterpolant','file')%recent Matlab versions
     1328                        F=scatteredInterpolant(coord_X, coord_Y,coord_X,'nearest');
     1329                        G=scatteredInterpolant(coord_X, coord_Y,coord_Y,'nearest');
     1330                    else
     1331                        F=TriScatteredInterp([coord_X coord_Y],coord_X,'nearest');
     1332                        G=TriScatteredInterp([coord_X coord_Y],coord_Y,'nearest');
     1333                    end
     1334                    Distx=F(XI,YI)-XI;% diff of x coordinates with the nearest measurement point
     1335                    Disty=G(XI,YI)-YI;% diff of y coordinates with the nearest measurement point
     1336                    Dist=Distx.*Distx+Disty.*Disty;
     1337                    for ivar=1:numel(VarVal)
     1338                        VarVal{ivar}(Dist>2*ProjData.CoordMesh)=NaN;% put to NaN interpolated positions too far from initial data
     1339                    end 
     1340                   
    13301341               
    13311342                ListVarName=(fieldnames(DataOut))';
Note: See TracChangeset for help on using the changeset viewer.