I have the function "mexFunction" and I have another function "afficheData"in another file and I defined the header .
/******************************************mexFunction.c************************************* ****/
Code:
#include <stdio.h>
#include <stdlib.h>
#include "mex.h"
#include "data_function.h"
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
double *sx, *sy, *coef;
int mc, nc, msx, msy, count = 0;
if (nrhs != 3)
{
mexErrMsgTxt("Three inputs required.");
}
sx = mxGetPr(prhs[0]);
msx = mxGetM(prhs[0]);
sy = mxGetPr(prhs[1]);
msy = mxGetM(prhs[1]);
coef = mxGetPr(prhs[2]);
mc = mxGetM(prhs[2]);
nc = mxGetN(prhs[2]);
afficheData("Coef", coef, mc, nc);
}
/*********************************data_function.h** ***************************************/
Code:
void afficheData(char *Name, double *Data, int M, int N);
/******************************data_function.c***** **************************************/
Code:
#include <stdio.h>
#include <stdlib.h>
#include "mex.h"
void afficheData(char *Name, double *Data, int M, int N)
{
int m, n;
mexPrintf("%s = \n", Name);
for(m = 0; m < M; m++, mexPrintf("\n"))
for(n = 0; n < N; n++)
mexPrintf("%8.4f ", Data[m + M*n]);
}
compilation error :
>> mex mexFunction.c
Writing library for mexFunction.mexw32
c:\users\abdou\appdata\local\temp\mex_wqly2n\mexfu nction.obj .text: undefined reference to '_afficheData'
C:\PROGRA~1\MATLAB\R2013A\BIN\MEX.PL: Error: Link of 'mexFunction.mexw32' failed.