Undefined function or variable

조회 수: 3 (최근 30일)
Linar
Linar 2011년 6월 19일
Hello,
I have a matlab file matlab_ode45_h.m:
function y = matlab_ode45_h(h, y0)
[T,Y] = ode45(@matlab_ft, [0 0.5*h h], y0);
y = Y(3,:);
I compile it using matlab compiler into a static library and call the function matlab_ode45_h from c++ code. I'm getting the following:
??? Undefined function or variable "h".
Error in ==> matlab_ode45_h at 4
How may this happen?
Thanks

답변 (1개)

Walter Roberson
Walter Roberson 2011년 6월 19일
That could happen if you do not pass anything in from C++ when you call matlab_ode45, or if somehow the argument marshaling between C++ and MATLAB is not set up correctly.
What C++ call are you using?
  댓글 수: 2
Linar
Linar 2011년 6월 19일
I've modified the matlab function (see above) since I'm solving ODE for h time units and not interested what's happening in between. But I'm still getting the similar error message.
This is how I call the matlab function:
double h_ = TimeStep;
double y0_[N];
//set y0_
mwArray h(1, 1, mxDOUBLE_CLASS, mxREAL);
h.SetData(&h_, 1);
mwArray y0(1, N, mxDOUBLE_CLASS, mxREAL);
y0.SetData(y0_, N);
mwArray y;
matlab_ode45_h(1, y, h, y0);
Kaustubha Govind
Kaustubha Govind 2011년 6월 20일
Do you call the MCR and library initialize and terminate functions in the right order? If yes and you still see the issue, could you try the documentation example and see if you can get it to work: http://www.mathworks.com/help/toolbox/compiler/f2-995712.html#f2-1009231

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

카테고리

Help CenterFile Exchange에서 Deploy to C++ Applications Using mwArray API (C++03)에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by