Can I use MATLAB to access a relational database such as Sybase, Oracle, or Informix?

3 views (last 30 days)
Can I use MATLAB to access a relational database, such as Sybase, Oracle, or Informix?
I would like to load data from a database into a MATLAB array.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 18 Apr 2023
Edited: MathWorks Support Team on 19 Apr 2023
The Database Toolbox allows you to access relational databases. The Database Toolbox supports importing and exporting of data from any ODBC or JDBC compliant RDBMS, and has been tested against the following database management systems:
IBM DB2 Universal Version 5
Informix Version 7.2.2
Ingres
Microsoft Access 95 or 97
Microsoft SQL Server Version 6.5 or 7.0
Oracle Version 7.3.3
Sybase SQL Server Version 11.0
Sybase SQL Anywhere Version 5.0
If you are upgrading from an earlier version of a database, such as Microsoft SQL Server Version 6.5, to a newer version, there is nothing special you need to do for the Database Toolbox. Just be sure to configure the data sources for the new version of the database application as you did for the original verison.
Please refer to the following URL for further information on the Database Toolbox:
If you do not have access to the Database Toolbox, you have a few indirect options of getting data from a database to MATLAB.
- Communicate via MEX-files
MEX-files are C or Fortran routines that can be run from within MATLAB. You can use MEX-files to access the database, using drivers that communicate with your particular database. From within the
MEX-file, access the drivers, which will retrieve the data, and then pass this data into the MATLAB workspace. For more information on MEX-files, please refer to the External Interface Guide.
- Retrieve the data into an ASCII file, and then read in the file
You could use SQL, SQR, RDO, or some other database communication language or reporting tool to retrieve the data, and then store this data into an ASCII file. You can then read this file into MATLAB, using the load command, or using MATLAB's low-level file I/O routines, such as fscanf. This is probably the easiest method.
- Retrieve the data and create a MAT-file
You could use a C or Fortran program to access database drivers which can retrieve the data, and then use our MAT-file library routines to create a MAT-file. You can then use a load command to get the data into MATLAB. Please refer to the External Interface Guide for information on creating MAT-files.
We do not provide database drivers or database communication languages, nor do we support their use. You may want to check with your database company to see what is available in the way of reporting tools and drivers.

More Answers (0)

Tags

Products

Community Treasure Hunt

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

Start Hunting!