I was doing some tests with reading data using MATLAB with PostgreSQL relational database and also using the PostGIS module.
In the database we have the advantage of creating our procedures and views and returning the data practically ready to analyze them, I’m saying this in the case of large structures.
I will describe below how to enable the PostgreSQL drive for MATLAB version R2017a and how to connect to the database and make three simple graphs with geographic coordinates and aircraft altitude.
1. Configuring the driver in MATLAB
Attention! I am using PostgreSQL version 10 but the only JDBC driver that worked for me was 8.4-703 JDBC 4 file postgresql-8.4-703.jdbc4.jar using a Windows-7 64 installed in a virtual machine.
- After downloading the file copy the same to the installation directory of MATLAB: C:\Program Files\MATLAB\R2017a
- Now edit the file as administrator: C:\Program Files\MATLAB\R2017a\toolbox\local\classpath.txt
- At the end of the file add the path to load the driver: C:\Program Files\MATLAB\R2017a\postgresql-8.4-703.jdbc4.jar
Now start the MATLAB within Apps you do tests with the Database Explorer, obviously you need to have a database set up for testing.
There is a document on the MATLAB website to make the installation you find useful by clicking here.
2. Creating a test class for the databases
MATLAB has some functions to access the database, you can see clicking here. I created a simple class called Database that connects to the database and returns a method containing my table of routes.
The above class will connect to the database and fetch the data in the procedure I want to view. Create another file named Avionic and add the code below.
In the code above we created three graphs to plot the route of the aircraft. Analyzing the information:
Press the F5 key to run the code, then click on your workspace to view the route data.
The first graph to show is the map of the geoshow() function plotting the route of the aircraft.
The next chart shows the scala without the map, the routes are written in KML format that can then be viewed in google maps or google earth.
The last chart uses the plot3d() function and takes into account the altitude of the aircraft.
3. Final considerations
IMHO, MATLAB is a very powerful, objective and easy-to-learn tool, it’s good for testing concepts and getting things done quickly, but not for scalar use.