# PetscViewerMatlabOpen

Opens a Matlab .mat file for input or output.

### Synopsis

    PetscErrorCode  PetscViewerMatlabOpen(MPI_Comm comm,const char name[],PetscFileMode type,PetscViewer *binv)

Collective on MPI_Comm

### Input Parameters

| comm | - MPI communicator
| name | - name of file
| type | - type of file

       FILE_MODE_WRITE - create new file for Matlab output

       FILE_MODE_READ - open existing file for Matlab input

       FILE_MODE_WRITE - open existing file for Matlab output

### Output Parameter

binv -PetscViewer for Matlab input/output to use with the specified file

### Note

This PetscViewer should be destroyed with PetscViewerDestroy().

For writing files it only opens the file on processor 0 in the communicator. For readable files it opens the file on all nodes that have the file. If node 0 does not have the file it generates an error even if other nodes do have the file.

### See Also

PetscViewerASCIIOpen(), PetscViewerSetFormat(), PetscViewerDestroy(),
VecView(), MatView(), VecLoad(), MatLoad()

Level:beginner
Location: src/sys/viewer/impls/matlab/vmatlab.c
Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages

### Examples

src/snes/examples/tutorials/ex30.c.html
src/dm/da/examples/tutorials/ex1.c.html