<div dir="ltr">Thanks a lot. <br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jul 29, 2022 at 12:11 PM Barry Smith <<a href="mailto:bsmith@petsc.dev">bsmith@petsc.dev</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;"><div><br></div>  If you already have Matlab matrices that were saved with, for example,<div><br></div><div>save example.mat A</div><div><br></div><div>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" target="_blank">https://petsc.org/release/docs/manualpages/Mat/MatLoad.html</a> for details and caveats.</div><div><br></div><div> <br><div><br><blockquote type="cite"><div>On Jul 29, 2022, at 12:00 PM, Jed Brown <<a href="mailto:jed@jedbrown.org" target="_blank">jed@jedbrown.org</a>> wrote:</div><br><div><div>You can use share/petsc/matlab/PetscBinaryWrite.m.<br><br>matlab> PetscBinaryWrite('matrix.petsc', sparse(A))<br><br>Then load it with MatLoad in PETSc.<br><br>Ahmed Mansur <<a href="mailto:ahmedlp9@gmail.com" target="_blank">ahmedlp9@gmail.com</a>> writes:<br><br><blockquote type="cite">How to import a sparse matrix from Matlab using C++ and PETSC , if anyone<br>has any example code, thanks<br></blockquote></div></div></blockquote></div><br></div></div></blockquote></div>