Programming Previous page   Next Page

The memmapfile Class

MATLAB implements memory-mapping using an object-oriented class called memmapfile. The memmapfile class has the properties and methods you need to map to a file, read and write the file via the map, and remove the map from memory when you are done.

Properties of the memmapfile Class

There are six properties defined for the memmapfile class. These are shown in the table below. These properties control which file is being mapped, where in the file the mapping is to begin and end, how the contents of the file are to be formatted, and whether or not the file is writable. One property of the file contains the file data itself.

Property
Description
Data Type
Default
data
Contains the data read from the file or to be written to the file. (See Reading a Mapped File and Writing to a Mapped File.)
Any of the numeric types
None
filename
Path and name of the file to map into memory. (See Selecting the File to Map.)
char array
None
format
Format of the contents of the mapped region, including data type, array shape, and variable or field name by which to access the data. (See Identifying the Contents of the Mapped Region.)
char array or N-by-3
cell array
uint8
offset
Number of bytes from the start of the file to the start of the mapped region. This number is zero-based. That is, offset 0 represents the start of the file. Must be a nonnegative integer value. (See Setting the Start of the Mapped Region.)
double
0
repeat
Number of times to apply the specified format to the mapped region of the file. Must be a positive integer value or Inf. (See Repeating a Format Scheme.)
double
Inf
writable
Type of access allowed to the mapped region. Must be logical 1 or logical 0. (See Setting the Type of Access.)
logical
false

You can set the values for any property except for data at the time you call the memmapfile constructor, or at any time after that while the map is still valid. Any properties that are not explicitly set when you construct the object are given their default values as shown in the table above. For information on calling the constructor, see Constructing a memmapfile Object.

Once a memmapfile object has been constructed, you can change the value of any of its properties. Use the objname.property syntax in assigning the new value. For example, to set a new offset value for memory map object m, type

To display the value of all properties of a memmapfile object, simply type the object name. For a memmapfile object m, typing the variable name m displays the following:

To display the value of any individual property, for example the writable property of object m, type


Previous page  Accessing Files with Memory-Mapping Constructing a memmapfile Object Next page

© 1994-2005 The MathWorks, Inc.