<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">Am 29.11.2019 um 09:14 schrieb Patrick Sanan <<a href="mailto:patrick.sanan@gmail.com" class="">patrick.sanan@gmail.com</a>>:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">PETSc has its own binary format, which is not the same as MATLAB's. <div class=""><br class=""></div><div class="">However, PETSc includes some MATLAB/Octave scripts which will load these binary files.</div><div class=""><br class=""></div><div class="">See $PETSC_DIR/share/matlab/PetscBinaryRead.m - there are some examples in the comments at the top of that file.</div></div></div></blockquote>Correction: $PETSC_DIR/share/petsc/matlab/PetscBinaryRead.m <blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">Note that you will probably want to add $PETSC_DIR/share/matlab to your MATLAB path so that you can run the script. This is what I have for Octave, but I'm not sure if it this, precisely, works in MATLAB:</div><div class=""><br class=""></div><div class=""><div class="">$ cat ~/.octaverc</div><div class="">PETSC_DIR=getenv('PETSC_DIR');</div><div class="">if length(PETSC_DIR)==0</div><div class="">  PETSC_DIR='~/code/petsc'</div><div class="">end</div><div class="">addpath([PETSC_DIR,'/share/petsc/matlab'])</div></div><div class=""><br class=""></div><div class="">(As an aside, note that there are also scripts included to load PETSc binary files to use with numpy/scipy in  Python, e.g. $PETSC_DIR/lib/petsc/bin/PetscBinaryIO.py)</div><div class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">Am 29.11.2019 um 04:07 schrieb baikadi pranay <<a href="mailto:pranayreddy865@gmail.com" class="">pranayreddy865@gmail.com</a>>:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hello PETSc users, <div class=""><br class=""></div><div class="">I have a sparse matrix built and I want to output the matrix for viewing in matlab. However i'm having difficulty outputting the matrix. I am writing my program in Fortran90 and I've included the following lines to output the matrix.</div><div class=""><br class=""></div><div class=""> <i class=""><b class="">call PetscViewerBinaryOpen(PETSC_COMM_SELF,'matrix',FILE_MODE_WRITE,view,ierr)<br class=""> call PetscViewerBinaryGetDescriptor(view,fd,ierr)<br class=""> call PetscBinaryWrite(fd,ham,1,PETSC_SCALAR,PETSC_FALSE,ierr)</b></i><br class=""></div><div class=""><br class=""></div><div class="">These lines do create a matrix but matlab says its not a binary file. Could you please provide me some inputs on where I'm going wrong and how to proceed with this problem. I can provide any further information that you might need to help me solve this problem. </div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Thank you.</div><div class=""><br class=""></div><div class="">Sincerely,</div><div class="">Pranay. </div></div>
</div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></body></html>