# HG changeset patch # User John W. Eaton # Date 1347342468 14400 # Node ID 9ed4fc294f3f9df51be4d0a6541d6ba78e4ab690 # Parent 6bdf379592d91fe2cb153b1708843c11ec397a7f when writing sparse matrices to MAT files, use nzmax of at least 1 (bug #36603) * ls-mat5.cc (save_mat5_binary_element): If nnz is 0, write 1 for nzmax in array flags element. diff --git a/libinterp/interp-core/ls-mat5.cc b/libinterp/interp-core/ls-mat5.cc --- a/libinterp/interp-core/ls-mat5.cc +++ b/libinterp/interp-core/ls-mat5.cc @@ -2429,6 +2429,10 @@ } os.write (reinterpret_cast (&flags), 4); + // Matlab seems to have trouble reading files that have nzmax == 0 at + // this point in the file. + if (nnz_32 == 0) + nnz_32 = 1; os.write (reinterpret_cast (&nnz_32), 4); write_mat5_tag (os, miINT32, dim_len);