Q:

How to select every row as an element in matlab

I have a function in matlab which accepts a nx1 matrix.
I have a matrix X of nx2 dims
How do I send matrix X to the function where every row of X goes as an element?

A:

Have a look at this matrix indexing in MATLAB article on the MathWorks website for information and examples of indexing matrices. To select rows from a matrix you can do something like the following:
>> m = rand(5, 2)

m =

    0.8147    0.0975
    0.9058    0.2785
    0.1270    0.5469
    0.9134    0.9575
    0.6324    0.9649

>> m(1,:)        

ans =

    0.8147    0.0975

>> m(end,:)      

ans =

    0.6324    0.9649

The first index of a matrix corresponds to the rows, the second corresponds to the columns. Here the : as the second index selects all the columns of the appropriate row. If you have a function func, and the matrix m from above you can pass each row of m to func as follows:
for i = 1:length(m)
    func(m(1,:)')
end

Note the transpose, which converts each row of m into a 2x1 array, i.e. a column vector, rather than a row vector.

