User`s manual

Examples of Fortran MEX-Files
3-15
MEX-file. Consequently, when returning to MATLAB, the output matrix must
be transposed.
This example places a string array/character matrix into MATLAB as output
arguments rather than placing it directly into the workspace. Inside MATLAB,
call this function by typing
passstr;
You will get the matrix mystring of size 5-by-15. There are some manipulations
that need to be done here. The original string matrix is of the size 5-by-15.
Because of the way MATLAB reads and orients elements in matrices, the size
of the matrix must be defined as
M=15 and N=5 from the MEX-file. After the
matrix is put into MATLAB, the matrix must be transposed.
C $Revision: 1.11 $
C==============================================================
C
C passstr.f
C Example for illustrating how to pass a character matrix
C from Fortran to MATLAB.
C
C Passes a string array/character matrix into MATLAB as
C output arguments rather than placing it directly into the
C workspace.
C
C This is a MEX-file for MATLAB.
C Copyright (c) 1984-2000 The MathWorks, Inc.
C==============================================================
subroutine mexFunction(nlhs, plhs, nrhs, prhs)
C--------------------------------------------------------------
C (pointer) Replace integer by integer*8 on the DEC Alpha
C platform.
C
integer plhs(*), prhs(*)
integer p_str, mxCreateString
C--------------------------------------------------------------
C
integer nlhs, nrhs
integer i
character*75 thestring