Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
Kaushik
Kaushik le 7 Juin 2013
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

Réponses (0)

Catégories

En savoir plus sur Write C Functions Callable from MATLAB (MEX Files) dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by