MAT.jl icon indicating copy to clipboard operation
MAT.jl copied to clipboard

BoundsError when struct contains 3D char array

Open TomRottier opened this issue 3 years ago • 1 comments

MWE:

In Matlab create struct with 3D char array and save as .mat

c1 = ['abc'; 'abc'];
char_array3D = cat(3, c1, c1)
s = struct('c', char_array3D)
save('s.mat', 's')

In Julia read .mat file containing 3D char array

using MAT
d = matread("s.mat")

TomRottier avatar Jun 26 '22 15:06 TomRottier

Note that behavior is different for v7.3 (HDF5 format).

save('s.mat', 's', '-v7.3')

Now I get UInt16 arrays

julia> matread("s.mat")["s"]["c"]
2×3×2 Array{UInt16, 3}:
[:, :, 1] =
 0x0061  0x0062  0x0063
 0x0061  0x0062  0x0063

[:, :, 2] =
 0x0061  0x0062  0x0063
 0x0061  0x0062  0x0063

matthijscox avatar Nov 14 '25 14:11 matthijscox