Mercurial > hg > octave-jordi
comparison examples/mystring.c @ 6593:3da1f4a41455
[project @ 2007-04-27 08:08:19 by dbateman]
author | dbateman |
---|---|
date | Fri, 27 Apr 2007 08:08:19 +0000 |
parents | |
children | 2aad75fcc93a |
comparison
equal
deleted
inserted
replaced
6592:8899e24ae362 | 6593:3da1f4a41455 |
---|---|
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 } |