23.06.2015 Views

MATLAB Programming

MATLAB Programming

MATLAB Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

6 Data Import and Export<br />

m.Data(60).y(:,6) = [1 2 3 4];<br />

% Generates an error.<br />

Thus, if you map an entire file and then append to that file after constructing<br />

the map, the appended data is not included in the mapped region. If you need<br />

to modify the dimensions of data that you have mapped to a memmapfile<br />

object, you must either modify the Format or Repeat properties for the object,<br />

or reconstruct the object.<br />

Examples. Two examples of statements that attempt to modify the<br />

dimensions of a mapped Data field are shown here. These statements result<br />

in an error.<br />

The first example attempts to diminish the size of the array by removing a<br />

row from the mapped array m.Data.<br />

m.Data(5) = [];<br />

The second example attempts to expand the size of a 50-row mapped array x<br />

by adding another row to it:<br />

m.Data(2).x(1:51,31) = 1:51;<br />

Writing Matrices to a Mapped File<br />

The syntax to use when writing to mapped memory can depend on what<br />

format was used when you mapped memory to the file.<br />

When Memory Is Mapped in Nonstructure Format. When you map a<br />

file as a sequence of a single data type (e.g., a sequence of uint16), you can<br />

use the following syntax to write matrix X to the file:<br />

m.Data = X;<br />

This statement is valid only if all of the following conditions are true:<br />

• The file is mapped as a sequence of elements of the same data type, making<br />

m.Data an array of a nonstructure type.<br />

• The class of X is the same as the class of m.Data.<br />

• The number of elements in X equals the number of elements in m.Data.<br />

6-62

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!