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/create_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
27 lines (23 sloc)
739 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 [X_grid, Y_grid] = create_grid(X, Y, grid_spacing) | |
% Function to create a rectangular grid from a set of scattered data points | |
% | |
% INPUTS: | |
% X, Y: scattered co-ordinates (pix.) | |
% grid_spacing: desired grid spacing (pix.) | |
% | |
% OUTPUTS: | |
% X_grid, Y_grid: co-ordinates on the rectangular grid (pix.) | |
% | |
% AUTHOR: | |
% Lalit Rajendran (lrajendr@purdue.edu) | |
% calculate min and max x,y co-ordinates of the point cloud | |
xmin = ceil(min(X)); | |
xmax = floor(max(X)); | |
ymin = ceil(min(Y)); | |
ymax = floor(max(Y)); | |
% generate 1D co-ordinate arrays for the grid | |
x_grid = xmin:grid_spacing:xmax; | |
y_grid = ymin:grid_spacing:ymax; | |
% generate 2D grid | |
[X_grid, Y_grid] = meshgrid(x_grid, y_grid); | |
end |