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

Topic: Equivalent to mxCreateDoubleMatrix for unsigned long
Replies: 1   Last Post: May 30, 2013 1:23 PM

Advanced Search

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

Posts: 19
Registered: 11/27/12
Equivalent to mxCreateDoubleMatrix for unsigned long
Posted: May 30, 2013 11:42 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hi,
I'd like to write mex functions from a 3rd party lib. The data type are all unsigned long. While looking at mex examples to create input and output, they are using mxCreateDoubleMatrix() with double type for both input and output.

Ex in timestwo.c:
===
void timestwo(double y[], double x[])
{
y[0] = 2.0*x[0];
}

void mexFunction( int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[] )
{
double *x,*y;
mwSize mrows,ncols;

/* Check for proper number of arguments. */
if(nrhs!=1) {
mexErrMsgTxt("One input required.");
} else if(nlhs>1) {
mexErrMsgTxt("Too many output arguments.");
}

/* The input must be a noncomplex scalar double.*/
mrows = mxGetM(prhs[0]);
ncols = mxGetN(prhs[0]);
if( !mxIsDouble(prhs[0]) || mxIsComplex(prhs[0]) ||
!(mrows==1 && ncols==1) ) {
mexErrMsgTxt("Input must be a noncomplex scalar double.");
}

/* Create matrix for the return argument. */
plhs[0] = mxCreateDoubleMatrix(mrows,ncols, mxREAL);

/* Assign pointers to each input and output. */
x = mxGetPr(prhs[0]);
y = mxGetPr(plhs[0]);

/* Call the timestwo subroutine. */
timestwo_usb(y,x);
}

I had a look at matrix.h but couldn't figure out how to create unsigned long type.
So, my question is, what is the equivalent of mxCreateDoubleMatrix() for unsigned long ?

Thanks for helping.



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-2017. All Rights Reserved.