Simulink block error. "Invalid sizes vector returned by MEX S-function"
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Sorry for the lack of information in this question. Doing research for someone and I've been given a huge amount of files to get running on Matlab.
The project I'm trying to run is a very detailed Simulink model. In the model, I am trying to run an S-function on my MEX file Core_Neutronics. The mex file I got was outdated. Had to convert it to .mexw64 first, which I'm pretty sure I did successfully by using the following code (filename was Core_Neutronics.c):
--------------
#include "mex.h"
/*
* Core_Neutronics.c
* This is a MEX-file for MATLAB.
*/
/*computation*/
void
mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
{
int i;
/* Examine input (right-hand-side) arguments. */
mexPrintf("\nThere are %d right-hand-side argument(s).", nrhs);
for (i=0; i<nrhs; i++) {
mexPrintf("\n\tInput Arg %i is of type:\t%s ",i,mxGetClassName(prhs[i]));
}
/* Examine output (left-hand-side) arguments. */
mexPrintf("\n\nThere are %d left-hand-side argument(s).\n", nlhs);
if (nlhs > nrhs)
mexErrMsgIdAndTxt( "MATLAB:mexfunction:inputOutputMismatch",
"Cannot specify more outputs than inputs.\n");
for (i=0; i<nlhs; i++) {
plhs[i]=mxCreateDoubleMatrix(1,1,mxREAL);
*mxGetPr(plhs[i])=(double)mxGetNumberOfElements(prhs[i]);
}
}
Then I set my MATLAB compiler to Visual Studio 12, and ran
mex Core_Neutronics.c
So I went ahead and tried to run Simulink again, but now I get an error that reads
Invalid sizes vector returned by MEX S-function 'Core_Neutronics' in 'Panther/PRX_Subsystem/S-Function'
Does anyone know why this is happening? I don't know that much about MATLAB. I do know that all of the variables coming out of my Core_Neutronics program are all 'double'.
Any help would be appreciated. Can't find anything on this error online.
Ryan
0 commentaires
Réponses (1)
Kaustubha Govind
le 4 Avr 2014
Modifié(e) : Kaustubha Govind
le 4 Avr 2014
What you have is a MEX-function meant for execution in MATLAB. You can run it like any other MATLAB function. An S-function looks like this: Basic C MEX S-Function. If you need to run MATLAB code in Simulink, you can one of three MATLAB Function blocks.
0 commentaires
Voir également
Catégories
En savoir plus sur Simulink Coder 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!