MATLAB Answers

Bart
0

How to get matlab to save acquired user input in a file/profile?

Asked by Bart
on 1 Dec 2014
Latest activity Commented on by Bart
on 1 Dec 2014
Hi,
I'm trying to collect information (car specifications) through a dialog-box, and then save this into a file/profile or something. So when you run the script a dialog-box pops up and you get to fill in blanks and then the script will put this information into a file and save this. Thereafter matlab will spit out all the data which can be calculated with the given information. Can someone explain me how to get matlab to save user input in a file, and how to recall this later? I'd be very thankful for your help.

  0 Comments

Sign in to comment.

1 Answer

Answer by Guillaume
on 1 Dec 2014
 Accepted Answer

You have plenty of options:
  1. Collect your input however you want into some variables (cell arrays, matrices, tables, whatever) and save these in a .mat file with save. To get the data back, just load the .mat file. Advantage: dead simple. Disadvantages: can only be read by matlab. Have to read or write everything at once.
  2. Same, but use a .mat file per user, and another main.mat file to keep track of the individual files. Advantages: fairly simple. A file per user. Disadvantage: can only be read by matlab.
  3. Save your data in a table. And use writetable, readtable to save/restore the data. Advantages: fairly simple, nice organisation of the data. Can be read by other software. Disadvantage: Everything in one file
  4. Save and read the data yourself using low level functions. Advantage: Use whatever format you wish (xml, json, etc.). Disadvantages: More code to write
  5. Save the data in a database. Advantage: Exactly designed for this type of storage. Disadvantages: requires the database toolbox or a fair amount of coding using COM or .Net interface.
  6. Use OOP, with objects representing your data. And save these objects as .mat file. Advantages: OOP advantages: encapsulation, inheritance, etc. Disadvantages: require a fair amount of coding.

  1 Comment

Thanks, thats exactly what i needed! I'll just play around with it now and hope i'll get to know how it works.

Sign in to comment.