Database Toolbox Previous page   Next Page

Viewing Information About the Imported Data

In this example, you view information about the data you imported and close the connection. You learn to use these Database Toolbox functions:

If you want to see or copy the functions for this example, or if you want to run the set of functions, use the M-file matlab\toolbox\database\dbdemos\dbinfodemo.m:

  1. If you are continuing directly from the previous example (Importing Data into MATLAB from a Database), skip this step. Otherwise, if the cursor and connection are not open, type the following to continue with this example.
  2. View the number of rows in the data set you imported by typing
  1. MATLAB returns

    rows returns the number of rows in the data set, which is 10 in this example.

  1. View the number of columns in the data set by typing
  1. MATLAB returns

    cols returns the number of columns in the data set, which is one in this example.

  1. View the column names for the columns in the data set by typing
  1. MATLAB returns

    columnnames returns the names of the columns in the data set. This example has only one column and, therefore, only one column name, 'country', is returned.

  1. View the width of the column (size of field) in the data set by typing
  1. MATLAB returns

    width returns the column width for the column number you specify. Here, the width of column 1 is 15.

  1. You can use a single function to view multiple attributes for a column by typing
  1. MATLAB returns

    Note that if you had imported multiple columns, you could include a colnum argument to specify the number of the column for which you want the information.

  1. Close the cursor by typing
  1. Always close a cursor when you are finished with it to avoid using memory unnecessarily and to ensure there are enough available cursors for other users.

  1. At this point, you can go to the next example. If you want to stop working now and resume with the next example at a later time, close the connection. Type

Previous page  Importing Data into MATLAB from a Database Exporting Data from MATLAB to a New Record in a Database Next page

© 1994-2005 The MathWorks, Inc.