User`s manual
Examples of C MEX-Files
2-17
This example takes an m-by-n structure matrix as input and returns a new
1-by-1 structure that contains these fields:
•String input generates an m-by-n cell array
•Numeric input (noncomplex, scalar values) generates an m-by-n vector of
numbers with the same class ID as the input, for example
int, double, and
so on.
* =============================================================
* phonebook.c
* Example for illustrating how to manipulate structure and cell
* array
*
* Takes a (MxN) structure matrix and returns a new structure
* (1x1) containing corresponding fields:for string input, it
* will be (MxN) cell array; and for numeric (noncomplex, scalar)
* input, it will be (MxN) vector of numbers with the same
* classID as input, such as int, double etc..
*
* This is a MEX-file for MATLAB.
* Copyright (c) 1984-2000 The MathWorks, Inc.
*=============================================================*/
/* $Revision: 1.6 $ */
#include "mex.h"
#include "string.h"
#define MAXCHARS 80 /* max length of string contained in each
field */
/* the gateway routine. */
void mexFunction( int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[] )
{
const char **fnames; /* pointers to field names */
const int *dims;
mxArray *tmp, *fout;
char *pdata;
int ifield, jstruct, *classIDflags;
int NStructElems, nfields, ndim;