How to create a new DAT file in matlab

Written by jim campbell
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to create a new DAT file in matlab
(Ciaran Griffin/Lifesize/Getty Images)

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:
Moderate

Other People Are Reading

Instructions

  1. 1

    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;

  2. 2

    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.

  3. 3

    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);

  4. 4

    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:

    fclose(file);

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the eHow.co.uk site, you consent to the use of cookies. For more information, please see our Cookie policy.