MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER Manuel d'utilisateur Page 93

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 408
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 92
Examples of C MEX-Files
2-33
At the MATLAB prompt, entering
full = eye(5)
full =
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
creates a full, 5-by-5 identity matrix. Using fulltosparse on the full matrix
produces the corresponding sparse matrix.
spar = fulltosparse(full)
spar =
(1,1) 1
(2,2) 1
(3,3) 1
(4,4) 1
(5,5) 1
Calling Functions from C MEX-Files
It is possible to call MATLAB functions, operators, M-files, and other MEX-files
from within your C source code by using the API function
mexCallMATLAB. This
example creates an
mxArray, passes various pointers to a subfunction to
acquire data, and calls
mexCallMATLAB to calculate the sine function and plot
the results.
/* $Revision: 1.4 $ */
/*=============================================================
* sincall.c
*
* Example for illustrating how to use mexCallMATLAB
*
* Creates an mxArray and passes its associated pointers (in
* this demo, only pointer to its real part, pointer to number of
* rows, pointer to number of columns) to subfunction fill() to
* get data filled up, then calls mexCallMATLAB to calculate sin
* function and plot the result.
*
Vue de la page 92
1 2 ... 88 89 90 91 92 93 94 95 96 97 98 ... 407 408

Commentaires sur ces manuels

Pas de commentaire