[petsc-users] MatViewAndMatlabLoad
Oo
wumeng07maths at qq.com
Sat Jul 19 11:20:03 CDT 2014
Hi Jed,
The matrix file's structure likes
==============================
%Size = n n
%Nonzeros = m
zzz = zeros(m, 3);
zzz = [
***
***
***
***
... ...
];
Mat_0x84000000_0 = spconvert(zzz);
================================
How can I read this file in Matlab?
Thanks,
Meng
------------------ Original ------------------
From: "Jed Brown";<jed at jedbrown.org>;
Date: Jul 18, 2014
To: "Oo "<wumeng07maths at qq.com>; "petsc-users"<petsc-users at mcs.anl.gov>;
Subject: Re: [petsc-users] MatViewAndMatlabLoad
Oo <wumeng07maths at qq.com> writes:
> Dear All,
>
>
> I met a problem about using "load()" function in Matlab to read a m file which describes a PETSc Mat object by :
> //Save coeff_matrix as a matlab file PetscViewer viewer; PetscViewerASCIIOpen(PETSC_COMM_WORLD,"CoeffMatrixFileName.m",&viewer); PetscViewerSetFormat(viewer, PETSC_VIEWER_ASCII_MATLAB); MatView(coeff_matrix, viewer); PetscViewerDestroy(&viewer);
> In Matlab, I used:M=load("CoeffMatrixFileName.m") and I got an error.The error is:???Error using ===> loadNumber of columns on line 2 of ASCII file CoeffMatrixFileName.m must be the same as previous lines.
What does the file look like?
Note that we recommend using a binary viewer and
A = PetscBinaryRead('binaryoutput')
to read in MATLAB. It is more accurate and much faster.
> Do you know how to deal with that error?Or Do you think there is some a mistake in my output of PETSc Mat Obj with the PetscViewer?
> Thank you~:)
> Meng
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20140720/507e4468/attachment-0001.html>
More information about the petsc-users
mailing list