[petsc-users] Read PetscInt in binary file from Matlab

Barry Smith bsmith at mcs.anl.gov
Wed Apr 17 15:48:46 CDT 2013


On Apr 17, 2013, at 11:02 AM, Hui Zhang <mike.hui.zhang at hotmail.com> wrote:

> Is there something similar to the Matlab function PetscBinaryRead for PetscInt?  The binary file is obtained by PetscIntView.

   If you look at the source for PetscIntView() you will see that it merely writes the raw integers directly to the file (with no header information). MATLAB provides routines for reading raw binary files, if you look at the source code for PetscBinaryRead.m you will see it merely opens the binary file with fopen(filename,rw,'ieee-be')) and then reads the data with fread(). So you can cook up a simple MATLAB script to read in the integers from the file.

   Barry


   



More information about the petsc-users mailing list