6593
|
1 #include <string.h> |
|
2 #include "mex.h" |
|
3 |
|
4 void |
|
5 mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) |
|
6 { |
|
7 int i, j, m, n; |
|
8 mxChar *pi, *po; |
|
9 |
|
10 if (nrhs != 1 || ! mxIsChar (prhs[0]) || |
|
11 mxGetNumberOfDimensions (prhs[0]) > 2) |
|
12 mexErrMsgTxt ("expecting char matrix"); |
|
13 |
|
14 m = mxGetM (prhs[0]); |
|
15 n = mxGetN (prhs[0]); |
|
16 pi = mxGetChars (prhs[0]); |
|
17 plhs[0] = mxCreateNumericMatrix (m, n, mxCHAR_CLASS, mxREAL); |
|
18 po = mxGetChars (plhs[0]); |
|
19 |
|
20 for (j = 0; j < n; j++) |
|
21 for (i = 0; i < m; i++) |
|
22 po [j*m + m - 1 - i] = pi [j*m + i]; |
|
23 } |