using std::vector<double> inside mexfunction()
1 view (last 30 days)
Show older comments
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 Comments
Answers (0)
See Also
Categories
Find more on Write C Functions Callable from MATLAB (MEX Files) in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!