Mex: Using arguments for definition an array
2 ビュー (過去 30 日間)
古いコメントを表示
Hello my friends :-)
I want to use the arguments from matlab in my mex/c-code and use them to define an array. Unfortunately an error appears. Can someone pls give a an advise for this problem? Many thanks for your help!
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
int sizeA;
mxArray *arg;
arg= prhs[0];
sizeA = mxGetScalar(arg);
int dim[3] = {100,3, sizeA}; // define array
0 件のコメント
採用された回答
James Tursa
2013 年 4 月 20 日
編集済み: James Tursa
2013 年 4 月 20 日
Some C compilers need to have all variable declarations first, before executable statements. So try this instead:
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
int sizeA;
mxArray *arg; // variable declaration
int dim[3] = {100,3, 0}; // variable declaration
arg = prhs[0];
sizeA = mxGetScalar(arg);
dim[2] = sizeA;
その他の回答 (0 件)
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!