the priority and benefits of saving data in .mat file
14 views (last 30 days)
Show older comments
farzad
on 10 Oct 2014
Edited: Bruno Pop-Stefanov
on 10 Oct 2014
Hi All
I would like to know, why would it be beneficial to use .mat files to save data to when it's very hard to review them at any time, and should always be loaded and also it can be written to mfile directly
I appreciate your attention
0 Comments
Accepted Answer
Bruno Pop-Stefanov
on 10 Oct 2014
Edited: Bruno Pop-Stefanov
on 10 Oct 2014
MAT files are compressed, binary files used to store data on the computer's hard drive. It is a convenient way to save data for future use and for sharing.
You can see the contents of the MAT file without loading it in the memory. Simply click on the MAT file in the Current Folder browser and the contents will be displayed below.
You can also load only one variable from a MAT file containing several variables with a simple command, without needing to load the entire file:
>> load mymatfile.mat variable
You can add variables to a MAT file gradually, when a MAT file already exists and already contains data. There is no need to re-write everything from the beginning:
>> save mymatfile.mat variable
If you don't want to use MAT file, the other alternative is to write the data to a binary file or a text file using the fprintf or fwrite functions, but it is obviously not as convenient as using MAT file. You would have to write your own read and write routines and the files will not be compressed.
For more information, you can refer to the following documentation page, which lists functions and tutorials for dealing with variables and MAT files:
0 Comments
More Answers (0)
See Also
Categories
Find more on File Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!