reading matlab binary files

Khan, Irfan irfan.khan at gatech.edu
Fri Feb 20 10:51:07 CST 2009


Hi

In an earlier email to the group Barry mentioned that if the matrix sizes are large, the output should be done in binary format and bin/matlab/PetscBinaryRead.m should be used to read the matrix into matlab. 

I have output the matrix in the following manner. 

       ierr   =  PetscViewerBinaryOpen(PETSC_COMM_WORLD, fname, FILE_MODE_WRITE, &viewer);
       ierr   =  PetscObjectSetName((PetscObject)obj.Amat,"Stiffness_matrix");
       ierr   =  MatView(obj.Amat,viewer);

I don't get any error messages during execution. However, when I have not been successful reading the matrix into matlab. Presently I get the following error messages.



??? Error using ==> fread
Invalid file identifier.  Use fopen to generate a valid file identifier.

Error in ==> PetscOpenFile.read at 5
d = fread(freader.fd,count,datatype);

Error in ==> PetscBinaryRead at 49
  header = read(fd,1,'int32');


Any suggestions to solve the problem?

Thanks
Irfan


More information about the petsc-users mailing list