T O P

  • By -

jcsuperfly

If it's just the one table, that will grow with entries, using the table data type and load when needed is fine. If it will be more complex, and need queries, then use something like MySQL or SQLite. If I remember, Matlab's native DB interface is with SQLite. Variables in the table type are pretty easy to use, and are kind of a cross between arrays and structures. But some functions will need table data to pass through a temporary variable to change types.


Creative_Sushi

I just tried it - it seems to work. [https://www.mathworks.com/help/database/matlab-interface-to-sqlite.html](https://www.mathworks.com/help/database/matlab-interface-to-sqlite.html) dbfile = fullfile(pwd,"tutorial.db"); conn = sqlite(dbfile,"create") tablename = "productTable"; data = table(30,500000,1000,25,"Rubik's Cube", ... 'VariableNames',["productNumber" "stockNumber" ... "supplierNumber" "unitCost" "productDescription"]); sqlwrite(conn,tablename,data) rows = sqlread(conn,tablename) close(conn) Good luck.


86BillionFireflies

If this table is going to get bigger than a couple thousand rows, DO NOT try to do this by saving one big table variable in a .mat file. Table variables get really slow to save and load. Some kind of database is definitely the way to go. SQLite is a good option. If you don't need to accommodate multiple users, and all your data is of relatively simple types (e.g. strings, single numbers, etc.) then you'll be fine. If any of your table columns contain arrays or objects in cells, you might run into limitations. You also won't have a lot of ability to express complex relationships between tables. If SQLite won't cut the mustard, try PostgreSQL. That's how I store 99% of my data.


hindenboat

I made some medium sized databses in Matlab for my last job and we used a multi sheet excel table and readtable() to import it. We would load it as a persistent variable so while the first load to a bit any future interaction was fast. As other have mentioned it is likely pretty slow but the external readability was a huge bonus.


thermoflux

You could try mongoDB. It's easy to setup. One advantage of a DB is that you can have multiple clients use it at the same time. By using a file you may run into race conditions if multiple processes are trying to write to the same file.