필터 지우기
필터 지우기

Mex: Using arguments for definition an array

조회 수: 2 (최근 30일)
mick strife
mick strife 2013년 4월 20일
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

채택된 답변

James Tursa
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;
  댓글 수: 1
mick strife
mick strife 2013년 4월 21일
thx for your effort :) that was really helpful

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Write C Functions Callable from MATLAB (MEX Files)에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by