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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| #include "mex.h"
#include <stdio.h>
#include <stdlib.h>
#define res(i1,j1) res[(i1)+row*(j1)]
#define x(i1, j1) x[(i1)+row*(j1)]
/*#######################************ Programme C hysteresis***********************####################*/
void copie(double *x,double *res, int row, int col)
{
int i1,j1;
for(i1=0;i1<row;i1++)
{
for(j1=0;j1<col;j1++)
{
res(i1,j1)=x(i1,j1);
}
}
}
/* nrhs nombre de parametre d'entre
nlhs nombre de parametre de sortie
prhs tableau de pointeur d'un element en entre
plhs tableau de pointeur de sortie
*/
void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
{
double *a,*c; /* a est le tableau en entre et c le tableau en sortie Matlab*/
int row,col;
/* Get inputs */
row = mxGetM(prhs[0]);
col = mxGetN(prhs[0]);
a = mxGetPr(prhs[0]); /* retourne la matrice pointée par prhs[0]*/
/* Create a matrix for the return argument. */
plhs[0] = mxCreateDoubleMatrix(row, col, mxREAL);
c = mxGetPr(plhs[0]);
/* main computation */
copie(a,c,row,col);
} |
Partager