%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % function sample_half() : Reduces a matrix by 1/2. % Odd columns are removed. % INPUT : m x n matrix. % OUTPUT: m x n/2 matrix % % Author: Jason Tate June 10, 1998 % tate@edcenter.sdsu.edu % % Educational Center for Computational Science & Engineering % http://www.edcenter.sdsu.edu % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function sampled = sample_half(ElevationMatrix) % DETERMINE DIMENSIONS OF MATRIX Dimensions = size(ElevationMatrix); numRows = Dimensions(1); numColumns = Dimensions(2); % INIT 'SAMPLED' MATRIX sampled = zeros(numRows,floor(numColumns/2) ); sampled_index = 1; % GO THRU EVERY COLUMN OF ELEVATIONMATRIX AND... for j = 1:numColumns % SAMPLE EVEN NUMBERED COLUMNS ONLY if (mod(j,2) == 0) sampled(:,sampled_index) = ElevationMatrix(:,j); sampled_index = sampled_index + 1; end end