Storing a .mat file in mysql database

38 views (last 30 days)
Hello again, I have a database in which i am storing certians bits of information, however i would like to store the whole .mat file related to this data.Mainly for the purpose if further analysis needs to be preformed on the dataset at a later point.
I have seen some research journals where people have done this and was hoping if someone could point me in the right direction please.
FYI running matlab 7.6.0(R2008a) and query builder is not working for me :(

Accepted Answer

Darik
Darik on 8 Aug 2013
If you absolutely have to do this, you could create a BLOB column in your database table, then in matlab use the fread function to grab the mat file as raw binary data, and then just insert that into the database. To get the data back out, you would then just fwrite the binary data to disk, and use the load function to read it into matlab.
The huge downside of this whole plan is of course the fact that you won't be able to query in any of the data in the matfile, which is usually the whole reason for storing stuff in a relational database in the first place.

More Answers (1)

Shashank Prasanna
Shashank Prasanna on 6 Aug 2013
Since MATLAB supports so many different types of data, you will have to load it into MATLAB first before committing it into a database.
You can start by going through some examples in the Database Toolbox:
Take a look at some of the full example workflows to get an idea of how to insert the data into a table.
  2 Comments
Shashank Prasanna
Shashank Prasanna on 8 Aug 2013
MAT file is very generic data container therefore I cannot answer your question with an Yes or No. It depends on what data you have within your mat file as I already mentioned.
You can simply write a function or script once to load the matfile and write the data into the specified database. And subsequently all you need to do is call that function again. Otherwise please clarify exactly what your workflow is.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!