00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "mex.h"
00021
00022 void
00023 mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
00024 {
00025 int i;
00026 char *str[100];
00027
00028
00029 if (nrhs < 2) {
00030 mexErrMsgTxt("At least two input arguments required.");
00031 }
00032 if(nlhs > 1){
00033 mexErrMsgTxt("Too many output arguments.");
00034 }
00035
00036 for (i=0; i<nrhs; i++){
00037
00038 if(!mxIsChar(prhs[i])){
00039 mexErrMsgTxt("Input must be of type char.");
00040 }
00041
00042 str[i] = mxArrayToString(prhs[i]);
00043 }
00044
00045
00046 plhs[0]= mxCreateCharMatrixFromStrings((mwSize)nrhs, (const char **)str);
00047
00048
00049 #if defined(SPACE_PADDING)
00050 {
00051 mwSize j;
00052 mwSize nelem = mxGetNumberOfElements(plhs[0]);
00053 mxChar *charData = (mxChar *)mxGetData(plhs[0]);
00054 for(j=0; j < nelem; j++) {
00055 if(charData[j] == (mxChar) 0) {
00056 charData[j] = (mxChar) ' ';
00057 }
00058 }
00059 }
00060 #endif
00061
00062 for (i=0; i<nrhs; i++){
00063 mxFree(str[i]);
00064 }
00065 }
00066