Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
executable file 24 lines (21 sloc) 666 Bytes
function f_grid = interpolate_to_grid(X, Y, f, X_grid, Y_grid)
% Function to interpolate a scalar on to a regular grid
%
% INPUTS:
% X, Y: co-ordinates of scattered data
% f: value of the scalar on the scattered data
% X_grid, Y_grid: co-ordinate grid to interpolate data
%
% OUTPUTS:
% f_grid: scalar interpolated onto the grid
%
% AUTHOR:
% Lalit Rajendran (lrajendr@purdue.edu)
% create interpolants
F = scatteredInterpolant(X, Y, f, 'natural');
F.ExtrapolationMethod = 'none';
% interpolate scalar onto the grid
f_grid = F(X_grid, Y_grid);
% replace NaNs by linear interpolation
f_grid = fillmissing(f_grid, 'linear');
end