openEMS/matlab/ReadHDF5FieldData.m

35 lines
1004 B
Matlab
Raw Normal View History

2010-04-05 21:16:52 +00:00
function hdf_fielddata = ReadHDF5FieldData(file)
% function hdf_fielddata = ReadHDF5FieldData(file)
%
% returns:
2010-05-28 13:13:45 +00:00
% hdf_fielddata.time
% hdf_fielddata.names
% hdf_fielddata.values
%
2010-05-28 13:13:45 +00:00
% example: values of timestep 12:
% hdf_fielddata.values{12}: array (x,y,z,polarization)
%
% plot z-field component along y-direction for timestep 12:
% plot( hdf_fielddata.values{12}(1,:,1,3) )
%
% openEMS matlab interface
% -----------------------
% author: Thorsten Liebig
2010-05-28 13:13:45 +00:00
%
% See also ReadHDF5Mesh ReadHDF5Dump
2010-04-05 21:16:52 +00:00
info = hdf5info(file);
for n=1:numel(info.GroupHierarchy.Groups)
if strcmp(info.GroupHierarchy.Groups(n).Name,'/FieldData')
for m=1:numel(info.GroupHierarchy.Groups(n).Datasets)
names{m} = info.GroupHierarchy.Groups(n).Datasets(m).Name;
2010-04-29 17:26:45 +00:00
hdf_fielddata.time(m) = double(info.GroupHierarchy.Groups(n).Datasets(m).Attributes.Value);
2010-04-05 21:16:52 +00:00
end
end
end
hdf_fielddata.names = names;
for n=1:numel(names)
2010-04-29 17:26:45 +00:00
hdf_fielddata.values{n} = double(hdf5read(file,names{n}));
2010-04-05 21:16:52 +00:00
end