output to matlab
Barry Smith
bsmith at mcs.anl.gov
Mon Feb 16 19:17:32 CST 2009
On Feb 16, 2009, at 7:05 PM, Yixun Liu wrote:
> Hi,
> I want to output matrix and vector into matlab.
> // output a vector,
> PetscViewer bviewer;
> PetscViewerCreate(PETSC_COMM_WORLD, &bviewer);
> PetscViewerSetType(bviewer, PETSC_VIEWER_ASCII);
> PetscViewerSetFormat(bviewer, PETSC_VIEWER_ASCII_MATLAB);
> PetscViewerFileSetName(bviewer, bname);
> VecView(externalForcesVector, bviewer);//externalForcesVector
> is a
> parallel vector.
>
PetscViewerDestroy(bviewer);
Run with -info to see what it says along the way.
BTW: If the matrix is large then you do not want to use an ASCII
viewer. You want to use a binary viewer and then use
bin/matlab/PetscBinaryRead() to read the vector into Matlab.
Barry
> However, the output file contains nothing.
>
> Thanks.
>
> Yixun
>
>
More information about the petsc-users
mailing list