Writing custom classes and hdf5
조회 수: 5 (최근 30일)
이전 댓글 표시
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
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.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 HDF5에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!