function [R]=addIndex2d(M) % addIndex(M) -- Adds an index column as the first column in a matrix MatrixLength = length(M); FinalIndex = transpose([1:MatrixLength]); R = [FinalIndex, M];