Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: how to pass cell of 3D matrices to C mex
Date: Thu, 27 Aug 2009 07:15:20 +0000 (UTC)
Organization: Boeing
Lines: 42
Message-ID: <h75bq8$jk6$1@fred.mathworks.com>
References: <h6tl9j$a0p$1@fred.mathworks.com> <h6tp1k$sja$1@fred.mathworks.com> <h72u3f$5qi$1@fred.mathworks.com> <h73knq$o06$1@fred.mathworks.com> <h74ttb$t3r$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1251357320 20102 172.30.248.35 (27 Aug 2009 07:15:20 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 27 Aug 2009 07:15:20 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 756104
Xref: news.mathworks.com comp.soft-sys.matlab:566332


"Ramana murthy" <omurthy@yahoo.com> wrote in message <h74ttb$t3r$1@fred.mathworks.com>...
> Hi james,
> I compiled your code. But I am getting some strange output
> 
> Cell array index 0
> data(1,1) = 8.41049e-288 
> data(1,2) = 5.45389e-312 
> data(1,3) = -9.60206e+303 
> 
> 
> I was expecting to print the individual elements(of matrix) of each entry of cell.
> 
> with regards,
> ramana

Your posted code had double * for the data type, so I assumed that was the data type being passed in. Your strange results are because the data type being passed in is not double. Just check what the data type is and then adjust the code accordingly. e.g., if the data type is int8, then change these lines:

    double *data;
                :
        data = mxGetPr(cell_element_ptr);
                        :
                mexPrintf("data(%i,%i) = %g \n", i+1, j+1, DATA(i,j));

to this:

    signed char *data;
                :
        data = mxGetData(cell_element_ptr);
                        :
                mexPrintf("data(%i,%i) = %d \n", i+1, j+1, DATA(i,j));

Or if the data is uint16, then change the lines to this:

    unsigned short *data;
                :
        data = mxGetData(cell_element_ptr);
                        :
                mexPrintf("data(%i,%i) = %d \n", i+1, j+1, DATA(i,j));

etc. etc.

James Tursa