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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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:
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 functionfunc, and the matrixmfrom above you can pass each row ofmtofuncas follows:Note the transpose, which converts each row of
minto a2x1array, i.e. a column vector, rather than a row vector.