Permalink
Cannot retrieve contributors at this time
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?
dot-tracking-package/interpolate_to_grid.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
executable file
24 lines (21 sloc)
666 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |