# mexGetMatrix, mexPutMatrix

## Purpose

Get and put Matrices into a MEX-file's caller's workspace.

## C Synopsis

    #include "mex.h"
    Matrix *mexGetMatrix(name)
      char *name;
    int mexPutMatrix(mp)
      Matrix *mp;

## Fortran Synopsis

    integer*4 function mexGetMatrix(name)
    integer*4 function mexPutMatrix(mp)
    integer*4 mp
    character*(*) name

## Arguments

`mp`
  Matrix pointer
`name`
  name of Matrix to get or put from workspace

## Description

These routines allow you to put a Matrix into a MEX-file's caller's workspace and to copy a Matrix out of the workspace.

`mexGetMatrix` reads the named Matrix from the caller's workspace and returns a pointer to a newly allocated Matrix structure, or `NULL` if the attempt fails.

`mexPutMatrix` writes Matrix `mp` to the caller's workspace. If the Matrix does not exist in the workspace, it is created. If a Matrix with the same name already exists in the workspace, the existing Matrix is replaced with the new Matrix.

`mexPutMatrix` returns 0 if successful and 1 if an error occurs.

Be careful in your code to free the Matrix created by this routine when you are finished with it.

(c) Copyright 1994 by The MathWorks, Inc.