Exporting Data from PostgreSQL Database to Matlab

To use the PostgreSQL database under Windows, you must select the package from the cygwin installation.
To link a database with Matlab, you need the Database toolbox distributed with Matlab.*

Instructions

(derived from Matlab's Help files on Database Toolbox and Logger.java written by Terence Tong)
  1. Edit the classpath used by MATLAB such that you load the JDBC drivers (they are used for connecting to the database).
    1. In UNIX, find the location of any files named *jdbc*.jar (* stands for wildcards)
    2. In MATLAB, type in edit classpath.txt to open up the MATLAB editor and add the path to the JAR file containing the JDBC drivers to the top of the list.
    3. Close and restart MATLAB.
  2. copy the file importDB.m to your matlab working directory.  Use this as a sample of how to access the database.  You should modify this file to suit your purposes.
  3. Remember to start up the database using startdb at the UNIX prompt before trying to connect to it through MATLAB.

Miscellaneous Help:

Simple PostgreSQL commands


* People have also written their own Matlab interfaces to Postgres and posted them online.  I have not tested any of these. 
Potentially useful sites for interfacing without the Database Toolbox:
  1. http://www.dertech.com/pgmex/pgmex.html
  2. http://www.math.toronto.edu/almgren/mysql/
  3. On MatlabCentral's File Exchange, the project named "postgres to MATLAB" by Rodrigo Oliveira