Bon ben je me lance...
Le fichier Dutmex.c :
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 #include "mex.h" void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int i, j, m ,n; double *M, *X, *P; m = mxGetM(prhs[0]); n = mxGetN(prhs[0]); M = mxGetPr(prhs[0]); X = mxGetPr(prhs[1]); plhs[0] = mxCreateDoubleMatrix(m, n, mxREAL); P = mxGetPr(plhs[0]); j=0; for (i = 0; i < m*n; i++) { j = (i / m); P[i]=M[i]-X[j]; } }
A compiler comme ceci :
Et le fichier m qui va avec :Code:mex Dutmex.c
Code:
1
2
3 function C = Dut(A,B); C = Dutmex(A,B);