Writing custom classes and hdf5

조회 수: 5 (최근 30일)
D. Plotnick
D. Plotnick 2016년 4월 27일
댓글: D. Plotnick 2016년 5월 3일
I am currently building custom class containers for a complicated data set. I am using classdef to define properties and methods at a number of levels. The actual data is all in known matlab formats, struct,double,cell, etc.
The end result is a custom database. I want to then export that database as an HDF5 file. That way anyone can load in the data without needing my custom class definitions. Again, the actual components of the database are simple matlab classes. I do not need to export methods with the data.
I am looking for a way to do this. Currently, if I attempt to use hdf5write on my custom database I (unsurprisingly) get:
'Custom_Database' is not a valid datatype for HDF5WRITE
Any help is greatly appreciated. I'll include a MWE below:
classdef Custom_Database
properties
props1
props2
end
methods
function obj = Custom_Database(N)
obj.props1 = rand(N);
obj.props2 = 'Random';
end
function obj = Manipulate_DB(obj)
obj.props1 = 2*obj.props1-1;
obj.props2 = 'RandFull';
end
end
end
I create a database with
tstDB = Custom_Database(100)
Ok, so I wind up with some "Database" with an array and a string in it. I then want to write this to an HDF5 format, since all I want to give to the user is props1 and props2 in some structure. I may manipulate the data myself, but I don't need to keep the methods themselves. However,
hdf5write('test','/here',tstDB)
returns 'Custom_Database' is not a valid datatype for HDF5WRITE
  댓글 수: 2
per isakson
per isakson 2016년 4월 28일
편집: per isakson 2016년 4월 28일
What release of Matlab do you use? Doc says: "Note: hdf5write will be removed in a future version. Use h5write instead."
Matlab high level functions can write numeric and character arrays to HDF5-files. You have to write a method that writes basic property values to the HDF5-file. See the documentation.
D. Plotnick
D. Plotnick 2016년 5월 3일
Currently 2015b, though I try to stay as up to date as time allows.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 HDF5에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by