Is it possible to use C++ string and sstream in MATLAB MEX?

조회 수: 2 (최근 30일)
AP
AP 2013년 2월 19일
Dear All,
Is it possible to use C++ string and sstream in a MATLAB MEX file? The following is a part of my code in which I am having problem:
string VariableNames;
ostringstream strout( VariableNames );
strout << "x y z ";
for( int i = 0; i<N; i++)
strout << GetComponentName( i ) << " ";
VariableNames = strout.str();
Although I have included string and sstream header files, MATLAB complains with the following error message:
error C2065: 'string' : undeclared identifier
Could someone tell me if using C++ string is usable in MEX.
Thanks,
Ahmad
  댓글 수: 3
Kaustubha Govind
Kaustubha Govind 2013년 2월 19일
You probably also need to add "using namespace std;", and ensure that your MEX-file has a .cpp extension.
AP
AP 2013년 2월 19일
Thanks @Kaustubha. Excellent catch. namespace was the problem.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Compiler에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by