The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: How to output a 2D integer array using Matlab mex?
Replies: 1   Last Post: Feb 15, 2014 5:38 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 110
Registered: 6/2/11
Re: How to output a 2D integer array using Matlab mex?
Posted: Feb 15, 2014 5:38 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I got the answer with the help from someone. I put it here for others' reference.

// Output the results
plhs[0] = mxCreateNumericMatrix(col_outputBuff, row_outputBuff, mxINT32_CLASS, mxREAL);
int* outputMatrix = (int *)mxGetData(plhs[0]);

// Read in the data
for (int col=0; col < col_outputBuff; col++) {
for (int row=0; row < row_outputBuff; row++) {
outputMatrix[row + col*row_outputBuff] = outputBuff[col][row];

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.