From: Xugang Ye on
Hello,

I have x, y in matlab as

x = ['--YLPTAERLTVVVVKAKNLIW---MNDKG----'
'--YLPSAGRLNVDVIRAKQLLQ---MDVSQ----'
'--YNPSANSIIVNIIKARNLKA---MDIGG----'
'--YVPTAGKLTVVILEAKNLKK---MDIGG----'
'DESPGLYGFLHVIIHSAKGFKQ------------'
'----VADEKLHVTVRDAKNLIP---MDING----'
'----VADEKLHVTVRDAKNLIP---MDING----'
'----VADEKLHVTVRDAKNLIP---MDING----'
'--PVISGGILHVFIKEAKNLTA---MDIGG----'
'--GLPPSGELHFWIKEARDLLP---MDIG-----'
'-----GVVQARGGIASAKEKPREGFMDIEQVPVS'];
y = 'ARNDCQEGHILKMFPSTWYV';

I want to pass then to c

In Mex function I use the following statements

char *x;
char *y;
x = mxGetPr(prhs[0]);
y = mxGetPr(prhs[1]);

But it does not work. Could anybody tell me how to pass x to c as a 2-D Array and pass y to c as an 1-D Array so that I can access x by *(x + i + j*M) and access y by *(y+i) ?

Thanks very much!
From: James Tursa on
"Xugang Ye" <yexugang(a)yahoo.com> wrote in message <i1h21j$26r$1(a)fred.mathworks.com>...
> Hello,
>
> I have x, y in matlab as
>
> x = ['--YLPTAERLTVVVVKAKNLIW---MNDKG----'
> '--YLPSAGRLNVDVIRAKQLLQ---MDVSQ----'
> '--YNPSANSIIVNIIKARNLKA---MDIGG----'
> '--YVPTAGKLTVVILEAKNLKK---MDIGG----'
> 'DESPGLYGFLHVIIHSAKGFKQ------------'
> '----VADEKLHVTVRDAKNLIP---MDING----'
> '----VADEKLHVTVRDAKNLIP---MDING----'
> '----VADEKLHVTVRDAKNLIP---MDING----'
> '--PVISGGILHVFIKEAKNLTA---MDIGG----'
> '--GLPPSGELHFWIKEARDLLP---MDIG-----'
> '-----GVVQARGGIASAKEKPREGFMDIEQVPVS'];
> y = 'ARNDCQEGHILKMFPSTWYV';
>
> I want to pass then to c
>
> In Mex function I use the following statements
>
> char *x;
> char *y;
> x = mxGetPr(prhs[0]);
> y = mxGetPr(prhs[1]);
>
> But it does not work. Could anybody tell me how to pass x to c as a 2-D Array and pass y to c as an 1-D Array so that I can access x by *(x + i + j*M) and access y by *(y+i) ?
>
> Thanks very much!

mxGetPr returns a double* type. You should use this with double class variables. For other numeric classes, use mxGetData. For char class variables, see mxArrayToString. You could use mxGetData and then skip every other character (MATLAB stores characters as 2 bytes per character), but the official function that MATLAB gives you for accessing character data is mxArrayToString.

James Tursa
 | 
Pages: 1
Prev: Selling Crossing job
Next: IMA ADPCm files format