% addgrid - add a matrix with grid lines of a certain value % % Usage: % gridMatrix = addgrid(cleanMatrix,rowIndex,colIndex,gridValue) % % % Arguments: % cleanMatrix - the matrix to be add grid on % rowIndex - the row index to add grid lines % colIndex - the column index to add grid lines % gridValue - the grid value % % Output: % gridMatrix - the gridded matrix, bigger size % % see also cleangrid.m % Author: % Tzu Yen Wong % wongt AT csse DOT uwa DOT edu DOT au % Department of Computer Science & Software Engineering % The University of Western Australia % % Dec 2003 % June 2004 change email address to fight SPAM!!! %1234567890123456789012345678901234567890123456789012345678901234567890123456789 function gridMatrix = addgrid(cleanMatrix,rowIndex,colIndex,gridValue) lengthc = length(colIndex); lengthr = length(rowIndex); [r,c] = size(cleanMatrix); gridMatrix = zeros(r+lengthr,c+lengthc); gridMatrix(1:r,1:c) = cleanMatrix; for ii=1:lengthr, grid_ii = rowIndex(ii); gridMatrix(grid_ii+1:r+ii,:) = gridMatrix(grid_ii:r+ii-1,:); gridMatrix(grid_ii,:) = gridValue; end for jj=1:lengthc, grid_jj = colIndex(jj); gridMatrix(:,grid_jj+1:c+jj) = gridMatrix(:,grid_jj:c+jj-1); gridMatrix(:,grid_jj) = gridValue; end