User`s manual
2 Creating C Language MEX-Files
2-20
if(mxIsChar(tmp)) {
mxSetCell(fout, jstruct, mxDuplicateArray(tmp));
} else {
size_t sizebuf;
sizebuf = mxGetElementSize(tmp);
memcpy(pdata, mxGetData(tmp), sizebuf);
pdata += sizebuf;
}
}
/* Set each field in output structure */
mxSetFieldByNumber(plhs[0], 0, ifield, fout);
}
mxFree(classIDflags);
return;
}
To see how this program works, enter this structure.
friends(1).name = 'Jordan Robert';
friends(1).phone = 3386;
friends(2).name = 'Mary Smith';
friends(2).phone = 3912;
friends(3).name = 'Stacy Flora';
friends(3).phone = 3238;
friends(4).name = 'Harry Alpert';
friends(4).phone = 3077;
The results of this input are
phonebook(friends)
ans =
name: {1x4 cell }
phone: [3386 3912 3238 3077]