Undefined function 'rows' for input arguments of type 'double'.

5 views (last 30 days)
How can I use the function "rows"? I have already installed the Database Toolbox but it is not working - or is it maybe the wrong toolbox? Thanks!
  2 Comments
Geoff Hayes
Geoff Hayes on 14 Nov 2014
Tim - how are you using the function rows? From the link, the only input to this function is a database cursor. Please post your code where you invoke rows and include any relevant code that precedes it.
If you are unsure if you have this function, type the following in the Commadn Window
which rows -all
As I don't have the Database Toolbox, I observe the following
'rows' not found.
What do you see when you run this command?
Tim
Tim on 14 Nov 2014
Edited: Tim on 14 Nov 2014
sam(:,4) = [1:1:rows(sam)]'
where sam is a matrix with 3 columns and around 2000 rows. I'm not sure if that are enough information for you - that are all information I can give you so far. I'm using MATLAB for the first time so sorry for the unclear information.
When I type in
which rows -all
I get the file
Applications/MATLAB_R2014a.app/toolbox/database/database/@cursor/rows.m % cursor method
What does cursor method mean in this context? I cannot find good information here on the MATLAB site.
Thanks a lot and sorry for my little knowledge.

Sign in to comment.

Answers (1)

Geoff Hayes
Geoff Hayes on 14 Nov 2014
Tim - the rows function of the Database Toolbox is to be used with a database cursor only where it is specified as an open SQL database cursor object generated using fetch. See fetch for details. So suppose you want to select some data/records from one or more tables in a database (Oracle, SQL Server, Sybase, etc). You write the SQL command to do this (something like select * from ... where ...) and then you execute this command against the database of interest. The cursor can then contain the records that are returned (which may include numeric, string, date, etc. data).
Since you are passing a 2000x3 matrix of data type double into the rows function, then the error makes sense - your matrix sam is not a cursor and so the Undefined function 'rows' for input arguments of type 'double' error message is raised.
What is your intent behind the line of code
sam(:,4) = [1:1:rows(sam)]'
You are setting the fourth column of sam to a column starting at one and incrementing by one until "something" is reached. What is that "something"?
If you are trying to determine the number of rows in sam, then use the size function as
numRows = size(sam,1);
We use 1 since that corresponds to the first dimension of sam, which is the number of rows.

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!