using std::vector<double> inside mexfunction()

조회 수: 3 (최근 30일)
Kaushik
Kaushik 2013년 6월 7일
hi,
i have the following
----myfunction.cpp------
#include<mex.h>
#include<math.h>
#include<matrix.h>
#include<stdio.h>
#include "mydllfunctionheader.h"
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
mystruct XXX;
XXX.a=0;
XXX.b.resize(10,0.);
mydllfunction(XXX);
}
----mydllfunctionheader.h----
#include <vector>
#include <map>
struct mystruct
{
double a;
std::vector<double> b;
}
__declspec(dllexport) int __cdecl
mydllfunction(mystruct XXX);
----------------------
problem is inside the mexfunction i make XXX.b to be of size 10 vector. but in the debug mode when i enter the mydllfunction the vector b gets messed up. any doubles (such as variable "a") are okay but any vectors are not okay.
Can anyone please comment on what is going on.
also i cannot have extern "C" before my _declspec. becuase though in the simple example i provide above i am returning int in the actual case i will be returning an complex object.
thanks in advance

답변 (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