MATLAB version 2018b provides a different exception identifier for the same situation than version 2017b did. Can you suggest the easiest way to handle this that works for both versions?
1 次查看(过去 30 天)
显示 更早的评论
% this same bit of code causes the identifier "MATLAB:imagesci:h5info:unableToFind"
% is there a better way to catch this exception that will work for both versions?
IMUstring = '/Nav_Data/'; % does this group exist in the hdf5 file?
try
h5info(full_h5_name,IMUstring);
catch err % No, so check for this group instead
if strcmp(err.identifier,'MATLAB:imagesci:h5info:libraryError')
IMUstring='/ER2_IMU/';
try
h5info(full_h5_name,IMUstring);
catch err % Not that group. One last option
IMUstring = '/ApplanixIMU/';
try
h5info(full_h5_name,IMUstring);
catch err % out of options. Alert the user to problem
if strcmp(err.identifier,'MATLAB:imagesci:h5info:libraryError')
error('problem identifying IMU in use. Did you give the correct filename?')
end
end
end
end
1 个评论
采纳的回答
Fangjun Jiang
2018-9-24
You didn't identify other errors. Is it necessary to identify this error, or you just simply need to catch an errors.
Anyway, I had to use version() or verLessThan() a few times to make my script working in different versions of MATLAB.
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!