0
votes

I am stuck in Matlab with the following code:

n = rows(returnport)-1;

I get the following error when running the code:

??? Undefined function or method 'rows' for input arguments of type 'double'.

Can someone help me with this? I use Matlab version 2011a.

2
You need to provide more code than what you have. If you are trying to get the number of rows in something simply call n = size(variable,1) where the second argument stands for the dimension you wish to get information about. Rows is a function in MATLAB except it is reserved for the Database Toolbox.MZimmerman6
are you sure this code was written for Matlab? As far as I know only Octave has implemented the function rows, Matlab is still lagging behind.carandraug
@carandraug If you read the question, it clearly states MATLAB, and it is also tagged as such.MZimmerman6
@MZimmerman6 so what? The author has a Matlab problem because some code he got code is using a non-Matlab function. A function that happens to be part of Octave. Answering that the code was actually written for Octave and not Matlab seems like a correct answer.carandraug
@carandraug the function also happens to be a part of MATLAB as well, so I am going off of the information that is provided.MZimmerman6

2 Answers

4
votes

rows() is a function of GNU Octave (same for columns()).

However, you can easily create those function and put them in your startup.m e.g.

>> rows = @(x) size(x,1)        

rows = 

     @(x)size(x,1)

 >> columns = @(x) size(x,2)

 columns = 

     @(x)size(x,2)

>> m=rand(7,3);
>> rows(m)

ans =

     7

>> columns(m)

ans =

     3
1
votes

If returnport is a matrix size(returnport,1) should give you the number of rows.