Home > custom > grid_tools > set_border.m

set_border

PURPOSE ^

PURPOSE: set bordercells of a grid to certain value

SYNOPSIS ^

function [grid] = set_border(grid,bs,bvalue)

DESCRIPTION ^

 PURPOSE:  set bordercells of a grid to certain value
 -------------------------------------------------------------------
 USAGE: [grid] = set_border(grid,ws,value)
 where: 
        [grid]  is the input grid 
        [bs]    is the border size in cells
        [bvalue] is the value to set border to, default is NaN
 -------------------------------------------------------------------------
 OUTPUTS:
        [grid]  is the altered grid
 -------------------------------------------------------------------

 Felix Hebeler, Geography Dept., University Zurich, Juli 2006.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [grid] = set_border(grid,bs,bvalue)
0002 % PURPOSE:  set bordercells of a grid to certain value
0003 % -------------------------------------------------------------------
0004 % USAGE: [grid] = set_border(grid,ws,value)
0005 % where:
0006 %        [grid]  is the input grid
0007 %        [bs]    is the border size in cells
0008 %        [bvalue] is the value to set border to, default is NaN
0009 % -------------------------------------------------------------------------
0010 % OUTPUTS:
0011 %        [grid]  is the altered grid
0012 % -------------------------------------------------------------------
0013 %
0014 % Felix Hebeler, Geography Dept., University Zurich, Juli 2006.
0015 if nargin < 2
0016     error('You need at least 2 input arguments for this function');
0017 end
0018 
0019 if ~exist('bvalue','var')
0020     bvalue=NaN;
0021 end
0022 if ischar(bvalue)
0023     bvalue=str2num(bvalue);% convert char 'nan' to NaN
0024 end
0025 
0026 grid(1:bs,:)=bvalue; %toprows
0027 grid(size(grid,1)-bs+1:size(grid,1),:)=bvalue; %bottom rows
0028 grid(:,1:bs)=bvalue; %left cols
0029 grid(:,size(grid,2)-bs+1:size(grid,2))=bvalue;

Generated on Tue 24-Feb-2009 19:14:50 by m2html © 2003