Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
27
Добавлен:
09.02.2015
Размер:
673.28 Кб
Скачать

It is written in the file. Each dimension in the file's datasets

matches the same dimension in the corresponding MATLAB variable.

Data translation rules:

(1) If the data is numeric, the HDF5 dataset contains an appropriate

HDF5 native datatype and the size of the dataspace is the same

size as the array.

(2) If the data is a string, the HDF5 file contains a single element

dataset, whose element is a null-terminated string.

(3) If the data is a cell array of strings, the HDF5 datatset or

attribute has an HDF5 string datatype. The dataspace has the

same size as the cell array. The string elements are

null-terminated, but all share the same maximum length.

(4) If the data is a cell array and all of the cells contain only

numeric data, the HDF5 datatype is an array. The elements of

the array must be all numeric and have the same size and type.

The dataspace of the array has the same dimensions as the cell

array. The datatype of the elements has the same dimensions as

the first element.

(5) If the data is a structure array, the HDF5 datatype will be a

compound type. Individual fields in the structure will employ

the same data translation rules for datatypes (e.g., cells

relate to strings or arrays, etc.).

(6) If the data is composed of HDF5 objects, the HDF5 datatype will

correspond to the type of the object.

- For H5ENUM objects, the dataspace has the same dimensions

as the object's Data field.

- For all other objects, the dataspace has the same

dimensions as the array of HDF5 objects passed to the

function.

Examples:

% (A) Write a 5-by-5 dataset of UINT8 values to the root group.

hdf5write('myfile.h5', '/dataset1', uint8(magic(5)))

% (B) Write a 2-by-2 string dataset in a subgroup.

dataset = {'north', 'south'; 'east', 'west'};

hdf5write('myfile2.h5', '/group1/dataset1.1', dataset);

% (C) Write a dataset and attribute to an existing group.

dset = single(rand(10,10));

dset_details.Location = '/group1/dataset1.2';

dset_details.Name = 'Random';

attr = 'Some random data';

attr_details.Name = 'Description';

attr_details.AttachedTo = '/group1/dataset1.2/Random';

attr_details.AttachType = 'dataset';

hdf5write('myfile2.h5', dset_details, dset, attr_details, attr, ...

'WriteMode', 'append');

% (D) Write a dataset using objects.

dset = hdf5.h5array(magic(5));

hdf5write('myfile3.h5', '/g1/objects', dset);

Please read the file hdf5copyright.txt for more information.

See also hdf5read, hdf5info, hdf5.

Reference page in Help browser

doc hdf5write

Hdf version 5 data objects

<hdf5.h5array> - Construct HDF5 array datatype object.

H5ARRAY Constructor for hdf5.h5array objects

hdf5array = hdf5.h5array;

hdf5array = hdf5.h5array(magic(5));

<hdf5.h5compound> - Construct HDF5 compound datatype object.

H5COMPOUND Constructor.

<hdf5.h5enum> - Construct HDF5 enumeration datatype object.

H5ENUM Constructor for hdf5.h5enum objects

HDF5ENUM = hdf5.h5enum;

HDF5ENUM = hdf5.h5enum({'RED' 'GREEN' 'BLUE'}, uint8([1 2 3]));

<hdf5.h5string> - Construct HDF5 string datatype object.

H5STRING Constructor for hdf5.h5string object.

HDF5STRING = hdf5.h5string('temperature');

<hdf5.h5vlen> - Construct HDF5 variable length array datatype object.

H5VLEN Constructor for an hdf5.h5vlen object.

HDF5STRING = hdf5.h5vlen({0 [0 1] [0 2] [0:10]});

Соседние файлы в папке Библиотеки Matlab