MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER Manuale Utente Pagina 93

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 408
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 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.
*
Vedere la pagina 92
1 2 ... 88 89 90 91 92 93 94 95 96 97 98 ... 407 408

Commenti su questo manuale

Nessun commento