External Interfaces Previous page   Next Page

Passing Arrays of Strings

Passing arrays of strings adds a slight complication to the example in the previous section, Passing Strings. Because MATLAB stores elements of a matrix by column instead of by row, it is essential that the size of the string array be correctly defined in the Fortran MEX-file. The key point is that the row and column sizes as defined in MATLAB must be reversed in the Fortran 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

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.

Typing

at the MATLAB prompt produces this result


Previous page  Passing Strings Passing Matrices Next page

© 1994-2005 The MathWorks, Inc.