<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div>  If you already have Matlab matrices that were saved with, for example,<div class=""><br class=""></div><div class="">save example.mat A</div><div class=""><br class=""></div><div class="">It may be possible to use MatLoad() directly on them using the PETSCVIEWERHDF5 viewer type (and not need to use the PetscBinaryWrite()). Please read the full manual page <a href="https://petsc.org/release/docs/manualpages/Mat/MatLoad.html" class="">https://petsc.org/release/docs/manualpages/Mat/MatLoad.html</a> for details and caveats.</div><div class=""><br class=""></div><div class=""> <br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Jul 29, 2022, at 12:00 PM, Jed Brown <<a href="mailto:jed@jedbrown.org" class="">jed@jedbrown.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">You can use share/petsc/matlab/PetscBinaryWrite.m.<br class=""><br class="">matlab> PetscBinaryWrite('matrix.petsc', sparse(A))<br class=""><br class="">Then load it with MatLoad in PETSc.<br class=""><br class="">Ahmed Mansur <<a href="mailto:ahmedlp9@gmail.com" class="">ahmedlp9@gmail.com</a>> writes:<br class=""><br class=""><blockquote type="cite" class="">How to import a sparse matrix from Matlab using C++ and PETSC , if anyone<br class="">has any example code, thanks<br class=""></blockquote></div></div></blockquote></div><br class=""></div></body></html>