[code=matlab]void mexFunction(int nlhs,mxArray**plhs,int nrhs,mxArray **prhs)
{
mxArray *param_in[5];
void *new_pr=NULL;
double TerrStation[3]={0,0,0};
struct *Earth_station station;
d2r=3.14/180;
station->h=0;
station->lat=72.03;
station->lon=23.43;
//bueno tendria que incluir como calculo los parametros rc y e_sq, pero vienen de un cuadro de dialogo, mas sucesivas operaciones, y realmente lo que me interesa no es eso
TerrStation[0] = (rc+station->h)*cos(station->lat*d2r)*cos(station->lon*d2r);
TerrStation[1] = (rc+station->h)*cos(station->lat*d2r)*sin(station->lon*d2r);
TerrStation[2] = (rc*(1-e_sq)+station->h)*sin(station->lat*d2r);//*ones(size(Y));
param_in[0]=mxCreateDoubleMatrix(3,1,mxREAL);
if(param_in[0]!=NULL)
{
new_pr=mxCalloc(3,sizeof(double));
if(new_pr!=NULL)
{
new_pr=TerrStation;
mxSetData(param_in[0],new_pr);
mexCallMATLAB(0,NULL,1,param_in,"plotterrstation");
}
mxFree(new_pr); //AQUI ME DA UN EXCEPCION DESCONOCIDA; Y LA VERDAD ES QUE NO SE PORQUE OCURRE ESTO CADA VEZ QUE LLAMO A MXFREE. NECESITO RESERVAR MEMORIA Y DESPUES LIBERARLA PORQUE SE TRATA DE UN PROGRAMA BASTANTE GRANDE
}
return;
}