Salut tout le monde,

Je veux utiliser des mex-files pour exécuter des programmes écris=ts en C dans matlab. J'ai essayé des exemples simples sur le web mais ça n'a pas marché.
Voilà l'exp

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
#include "mex.h"
#include <math.h>
 
void timestwo(double y[], double x[])
{
  y[0] = 2.0*x[0];
  return;
}
 
void mexFunction( int nlhs, mxArray *plhs[],     
                  int nrhs, const mxArray *prhs[] ) 
{ double *y;
  double *x;
  unsigned int m, n;
 
  /* Check for proper number of arguments. */
  if (nrhs !=1) {
    mexErrMsgTxt("Only one input argument allowed."); }
  else if (nlhs !=1) {
    mexErrMsgTxt("Only one output argument allowed."); }
 
  /* The input x must be a scalar, get the size of x. */
  m = mxGetM(prhs[0]);  /* rows    */
  n = mxGetN(prhs[0]);  /* columns */
  if (!mxIsNumeric(prhs[0]) || mxIsComplex(prhs[0])
      || mxIsSparse(prhs[0]) || !mxIsDouble(prhs[0])
      || !(m ==1 && n ==1))
  {
    mexErrMsgTxt("Input x must be a scalar.");
  }
 
  /* Create a matrix for the return argument. */
  plhs[0] = mxCreateDoubleMatrix(m, n, mxREAL);
  /* Assign pointers to each input and output. */
  y = mxGetPr(plhs[0]);
  x = mxGetPr(prhs[0]);
  /* Call the timestwo subroutine. */
  timestwo(y, x);
}
Je l'ai enregistré sous "timestwo.c".

Sous matlab, j'ai fait:
ça me crée la .dll

et quand je l'exécute
par exemple
ça m'affiche cette erreur
??? Only one input argument allowed.
Quelqu'un pourra-il m'aider, peut être je manquait une instruction sous matlab.

Merci d'avance