% % @file h5Complex.m % % @brief % % @copyright % Copyright (©) 2021 EPFL (Ecole Polytechnique Fédérale de Lausanne) % SPC (Swiss Plasma Center) % % SPClibs is free software: you can redistribute it and/or modify it under % the terms of the GNU Lesser General Public License as published by the Free % Software Foundation, either version 3 of the License, or (at your option) % any later version. % % SPClibs is distributed in the hope that it will be useful, but WITHOUT ANY % WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. % % You should have received a copy of the GNU Lesser General Public License % along with this program. If not, see . % % @authors % (in alphabetical order) % @author Trach-Minh Tran % function z = h5Complex(file, dset) data = hdf5read(file, dset); dims = size(data); rank = size(dims,2); switch rank case {1} for i=1:dims(1) z(i)=complex(cell2mat(data(i,1).Data(1)), cell2mat(data(i,1).Data(2))); end case {2} for i=1:dims(1) for j=1:dims(2) z(i,j)=complex(cell2mat(data(i,j).Data(1)), cell2mat(data(i,j).Data(2))); end end case {3} for i=1:dims(1) for j=1:dims(2) for k=1:dims(3) z(i,j,k)=complex(cell2mat(data(i,j,k).Data(1)), cell2mat(data(i,j,k).Data(2))); end end end end