Working with SQLite database in Matlab

SQLiteYou might have already wonder how you could deal with large amount of data taken in lab ? For example, you might have led some experiences with different conditions / hypothesis, performed measurements and store the resulting raw samples into files given them a unique name with the corresponding experience conditions. For example, say you have two parameters var1 and var2 which could take value in {'a', 'b', 'c'} and {'A','B','C'} respectively. Your file names will then be something like 'file1-a-A.txt', 'file1-a-B.txt', 'file1-b-C.txt', 'file2-a-A.txt' and so on... Each file contains the result of the measurement, for example raw samples of a unique variable. That said you need to develop a tool to interpreat the results as you might want to average all results with var1='a', plot all results of var1='b' and var2='C' etc. This is a perfect case to use a database because sorting and querying is the core of a database. Of course you could always build your own way to query your results, but you will have to code a new program each time you would like to change the conditions of the experiment to plot the result.

The solution I propose here is to build a custom SQLite database with Matlab and the corresponding .NET assembly. Why SQLite ? because you don't need any server as the database is store under a simple file. And why .NET ? because... there is no reason except that I am more comfortable with it, the framework is simple to use. You could have chosen to use the equivalent embedded Java framework. So lets start.

At first, in order to be used each time you want to use a database, the best is to create a class of tools to manipulate easily the database. Here is the code.


Leave a Reply

%d bloggers like this: