ABSTRACT

Both R and MATLAB platforms are designed to work natively with vectors and matrices. Many of the standard functions to perform basic mathematical calculations are vectorized, meaning they will operate on all elements of a vector or matrix. In a non-vectorized platform like the C programming language, a for loop would be needed to iterate over the elements of the vector or matrix. One very useful operation is to apply a function to parts of a matrix. It can be useful to do this along a certain dimension of a matrix. R has the very useful function apply which lets one apply a function along particular dimensions of a matrix. MATLAB does not have a function directly equivalent to R's apply, but there is a way to achieve the same effect. The cellfun function can then be used to apply a given function to that cell array, i.e., the rows or columns of the original matrix.