Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


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

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 ]
Aaronne

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]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.