Matlab is a derivative of the C++ programming language. Matlab is used for scientific calculations and creating small, low-level applications. The .DAT file format allows you to create binary files, so you can store software preferences, private data or passwords without enabling users to read the data. Matlab uses the C++ data structures to create DAT files. You create these files anywhere in your code, and the DAT file is stored to the user's computer for later use.
- Skill level:
Create your file handler. A file handler is a Matlab variable that contains the location of the file you create. The following code creates the file handler:
FILE * file;
Create the DAT file. You use the "fopen" function to create files in Matlab. The following code creates your file:
file = fopen('myfile.dat','w');
The "w" letter in this line of code indicates to the compiler that you want to "write" data to the file. If you want to simply read the file, use the "r" character.
Write some data to the DAT file. The following code writes a simple line of text to your file:
fputs ("my first dat file",file);
Close the file. After you are finished writing to the DAT file, close it to release it from memory. The following code closes the file:
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for