Download 7 - Parent Directory
Transcript
Examples of C MEX-Files
#include "mex.h"
/* Computational subroutine */
void convec(double *xr, double *xi, int nx, double *yr,
double *yi, int ny, double *zr, double *zi)
{
int i,j;
zr[0] = 0.0;
zi[0] = 0.0;
/* Perform the convolution of the complex vectors. */
for (i = 0; i < nx; i++) {
for (j = 0; j < ny; j++) {
*(zr+i+j) = *(zr+i+j) + *(xr+i) * *(yr+j) - *(xi+i)
* *(yi+j);
*(zi+i+j) = *(zi+i+j) + *(xr+i) * *(yi+j) + *(xi+i)
* *(yr+j);
}
}
}
Below is the gateway routine that calls this complex convolution.
/* The gateway routine. */
void mexFunction(int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[])
{
double *xr, *xi, *yr, *yi, *zr, *zi;
int
rows, cols, nx, ny;
/* Check for the proper number of arguments. */
if (nrhs != 2)
mexErrMsgTxt("Two inputs required.");
if (nlhs > 1)
mexErrMsgTxt("Too many output arguments.");
/* Check that both inputs are row vectors. */
if (mxGetM(prhs[0]) != 1 || mxGetM(prhs[1]) != 1)
mexErrMsgTxt("Both inputs must be row vectors.");
rows = 1;
4-21
Related documents
External Interfaces
MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER User`s manual
External Interfaces/API
3 - McMaster Physics and Astronomy
MATLAB Compiler
ME964 GIT, Trac, CMake & CUDA Debugging
Instrument Control Toolbox
Instrument Control Toolbox User`s Guide
Link to the user and technical guide
GE SMARTHOME 45227-1 User's Manual
SR1 Operations Manual - Stanford Research Systems
Séminaire MATLAB - MATLAB à vol d`oiseau