MEX file for MATLAB - help needed

Status
Not open for further replies.

semen2006

Newbie level 2
Joined
Sep 18, 2009
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,295
MEX file for MATLAB

Why don`t its mex file in matlab? Help me? please.

/* function y = timestwo_alt(z,x,N) */

#include <math.h>
#include <stdio.h>
#include "mex.h"


void timestwo_alt(double *z, double *x, double y[], int N)
{

int i;

for(i=0; i<N; i++) {

y = *z*i+*x;
}
}

void mexFunction(int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[])
{

double *y;
double *z,*x;

int N, NN;
int mrows;
/*
mrows = mxGetM(plhs[0]);
y = mxGetPr(plhs[0]); */

/* NN=sizeof(*y);*/


/* Create a 1-by-1 matrix for the return argument. */
plhs[0] = mxCreateDoubleMatrix(N,1, mxREAL);


/* Get the scalar value of the input x. */
/* Note: mxGetScalar returns a value, not a pointer. */
x = mxGetPr(prhs[1]);
z = mxGetPr(prhs[0]);
N = mxGetScalar(prhs[2]);
/* NN = mxGetM(prhs[2]);

/* Assign a pointer to the output. */

y = mxGetPr(plhs[0]);


/* Call the timestwo_alt subroutine. */
timestwo_alt(z,x,y,N);
}
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…