[petsc-users] Import Matlab matrix

Ahmed Mansur ahmedlp9 at gmail.com
Fri Jul 29 11:59:56 CDT 2022


Thanks a lot.

On Fri, Jul 29, 2022 at 12:11 PM Barry Smith <bsmith at petsc.dev> wrote:

>
>   If you already have Matlab matrices that were saved with, for example,
>
> save example.mat A
>
> 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
> https://petsc.org/release/docs/manualpages/Mat/MatLoad.html for details
> and caveats.
>
>
>
> On Jul 29, 2022, at 12:00 PM, Jed Brown <jed at jedbrown.org> wrote:
>
> You can use share/petsc/matlab/PetscBinaryWrite.m.
>
> matlab> PetscBinaryWrite('matrix.petsc', sparse(A))
>
> Then load it with MatLoad in PETSc.
>
> Ahmed Mansur <ahmedlp9 at gmail.com> writes:
>
> How to import a sparse matrix from Matlab using C++ and PETSC , if anyone
> has any example code, thanks
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20220729/6f5d3374/attachment.html>


More information about the petsc-users mailing list