mexGetMatrixPtr

Purpose

Get the pointer to a Matrix in the caller's workspace.

C Synopsis

#include "mex.h"
Matrix *mexGetMatrixPtr(name)
  char *name;

Fortran Synopsis

integer*4 function mexGetMatrixPtr(name)
character*(*) name

Arguments

name
name of Matrix in caller's workspace

Description

This routine returns a pointer to the Matrix with the specified name in the workspace local to the calling function. It allows you to read or modify variables in the MATLAB workspace directly from a MEX-file.

In computer science terminology, mexGetMatrix does a "get by value" whereas mexGetMatrixPtr does a "get by reference."

Do not free or reallocate the memory associated with any part of a Matrix obtained with this function, including the real part, imaginary part, and sparse structure. Matrices obtained with this function are managed by MATLAB's own internal mechanisms and MATLAB will crash immediately if you change anything.

This function can be used to read the values from a Matrix in the workspace, or to changes those values, provided the Matrix remains the same size, complexity, and sparsity.

To get the pointer of a global variable that is not defined as global by the calling function, first declare it global with a call of the form mexEvalString("global varname").

(c) Copyright 1994 by The MathWorks, Inc.