Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top