Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: [MEX] mxCreateStructMatrix in Fortran
Date: Wed, 19 Nov 2008 13:04:02 +0000 (UTC)
Organization: AGFA-Gevaert
Lines: 46
Message-ID: <gg12s2$ajt$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1227099842 10877 172.30.248.38 (19 Nov 2008 13:04:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 19 Nov 2008 13:04:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1013433
Xref: news.mathworks.com comp.soft-sys.matlab:501709


Hello everyone,

I'm having problems using mxCreateStructMatrix.

I created a gateway function in Fortran ("test.F") looking like this :

#include <fintrf.h>
C
C TESTSTRUCT.F - Gateway function for TESTSTRUCT.F

      SUBROUTINE MEXFUNCTION(NLHS, PLHS, NRHS, PRHS)

      MWPOINTER PLHS(*), PRHS(*)
      INTEGER NLHS, NRHS
      MWPOINTER MXCREATEDOUBLEMATRIX, MXGETPR, MXCREATESTRUCTMATRIX

C VARIABLES DECLARATION
C--------------------------------------------------------------------------
      REAL*4 NBFILD
      CHARACTER*12 FIELDS(6)

C VARIABLES INITIALISATION
C--------------------------------------------------------------------------
      NBFILD= 6
      FIELDS(1)='One'
      FIELDS(2)='Two'
      FIELDS(3)='Three'
      FIELDS(4)='Four'
      FIELDS(5)='Five'
      FIELDS(6)='Six'
      PLHS(1) = MXCREATESTRUCTMATRIX(1, 1, NBFILD, FIELDS)
      
      RETURN
      END

I compiled it using "mex test.F". As you can see, it should do nothing but give back en empty structure matrix, but when I run :
A = test()
Matlab returns :
??? Out of memory. Type HELP MEMORY for your options.

I know for sure it is comming from MXCREATESTRUCTMATRIX (I ran some tests).

Any idea what I'm doing wrong ?

Thanks a lot in advance,
Fran?ois.