How can I write to HDF5 data set on a Simulink-Realtime target machine?
2 次查看(过去 30 天)
显示 更早的评论
I need to write data into a HDF5 data set on a simulink-realtime target machine. Within the simuink model for my target system I wrote a matlab function with the following code for creation of the hdf5 data set:
coder.cinclude('C:\Program Files\HDF_Group\HDF5\1.10.1\include\hdf5.h');
% declare variable fname (string variable for file name) as a 1-by-32 vector of uint8 without performing an unnecessary initialization
fname = coder.nullcopy(uint8(zeros(1, 32)));
% H5F_ACC_TRUNC = coder.nullcopy(uint8(zeros(1,1)));
% H5Fpublic.h (52): #define H5F_ACC_TRUNC (H5CHECK H5OPEN 0x0002u) /*overwrite existing files */
H5F_ACC_TRUNC = uint8(2);
% /* Default value for all property list classes */
% #define H5P_DEFAULT (hid_t)0
H5P_DEFAULT = coder.opaque('hid_t','0');
% Call external C/C++ function 'sprintf' and write filename into string
% variable fname
coder.ceval('sprintf', coder.wref(fname), ['file.h5', 0]);
file_id = coder.opaque('hid_t'); %/* file identifier */
status = coder.opaque('herr_t');
%/* Create a new file using default properties. */
file_id = coder.ceval('H5Fcreate', fname, H5F_ACC_TRUNC, H5P_DEFAULT , H5P_DEFAULT);
%/* Terminate access to the file. */
status = coder.ceval('H5Fclose',file_id);
Unfortunately I get the following error when trying to compile:
error LNK2019: Reference to unresolved external symbol "H5Fcreate"
error LNK2019: Reference to unresolved external symbol "H5Fclose"
Presumably I somehow have to link the hdf5 libs, but I could not figure out how to do this.
Can anyone help?
0 个评论
采纳的回答
Nikhil Sreekumar
2017-10-3
Hi Jannes,
The library and associated header file should be included in both the Custom Code section for Simulation Target and under Code Generation. Simulation modes that use code generation (such as Accelerator mode) will still work as the Simulation Target includes are set up correctly.
Under the Code Generation -> Custom Code section, the option for "Use the same custom code settings as Simulation Target" can be selected.
Thanks,
Nikhil
0 个评论
更多回答(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!