Hi every one , when i execute this code i get this message "Error in 'essai/S-Function' while executing C MEX S-function 'MLI', (mdlOutputs), at time 0.0 FatalException
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
#define S_FUNCTION_LEVEL 2
#define S_FUNCTION_NAME MLI
#include "simstruc.h"
#include <math.h>
#define NumContStates 0 /* number of continuous states */
#define NumDiscStates 0 /* number of discrete states */
#define NumInputs 3 /* number of inputs */
#define InputPortWidth1 1 /* width of the input port*/
#define InputPortWidth2 1 /* width of the input port*/
#define InputPortWidth3 1 /* width of the input port*/
#define NumOutputs 2 /* number of outputs */
#define OutputPortWidth1 1 /* number of outputs */
#define OutputPortWidth2 1 /* number of outputs */
#define DirectFeedThrough1 0 /* direct feedthrough flag */
#define DirectFeedThrough2 0 /* direct feedthrough flag */
#define DirectFeedThrough3 0 /* direct feedthrough flag */
#define NumSampleTimes 1 /* number of sample times */
#define NumParams 1 /* number of input arguments */
#define NumRWork 0 /* number of real work vector elements */
#define NumIWork 0 /* number of integer work vector elements */
#define NumPWork 0 /* number of pointer work vector elements */
#define Ts mxGetPr(ssGetSFcnParam(S,0))[0]
static void mdlInitializeSizes(SimStruct *S)
{
ssSetNumContStates(S, NumContStates);
ssSetNumDiscStates(S, NumDiscStates);
if (!ssSetNumInputPorts(S, NumInputs)) return;
ssSetInputPortWidth(S, 0, InputPortWidth1);
ssSetInputPortWidth(S, 1, InputPortWidth2);
ssSetInputPortWidth(S, 2, InputPortWidth3);
if (!ssSetNumOutputPorts(S, NumOutputs)) return;
ssSetOutputPortWidth(S, 0, OutputPortWidth1);
ssSetOutputPortWidth(S, 1, OutputPortWidth2);
ssSetInputPortDirectFeedThrough(S, 0, DirectFeedThrough1);
ssSetInputPortDirectFeedThrough(S, 1, DirectFeedThrough2);
ssSetInputPortDirectFeedThrough(S, 2, DirectFeedThrough3);
ssSetNumSampleTimes(S, NumSampleTimes);
ssSetNumSFcnParams(S, NumParams);
if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
return;
}
ssSetNumRWork(S, NumRWork);
ssSetNumIWork(S, NumIWork);
ssSetNumPWork(S, NumPWork);
}
static void mdlInitializeSampleTimes(SimStruct *S)
{
ssSetSampleTime(S, 0, Ts);
ssSetOffsetTime(S, 0, 0.0);
}
static void mdlInitializeConditions(double *x0, SimStruct *S){}
static void mdlOutputs(SimStruct *S, int_T tid)
{
real_T *y1 = ssGetOutputPortRealSignal(S, 0);
real_T *y2 = ssGetOutputPortRealSignal(S, 1);
InputRealPtrsType ref = ssGetInputPortRealSignalPtrs(S,0);
InputRealPtrsType car1 = ssGetInputPortRealSignalPtrs(S,1);
InputRealPtrsType car2 = ssGetInputPortRealSignalPtrs(S,2);
double S1,S2;
if ( *ref[0] >= *car1[0] )
{
S1 = 1;
S2 = 1;
}
else if ((*ref[0] < *car1[0]) && (*ref[0] > *car2[0]))
{
S1 = 1;
S2 = 0;
}
else
{
S1 = 0;
S2 = 0;
}
// Outputs:
y1[0] = S1;
y2[0] = S2;
}
#define MDL_UPDATE
static void mdlUpdate(SimStruct *S, int_T tid){}
#define MDL_DERIVATIVES
static void mdlDerivatives(SimStruct *S){}
static void mdlTerminate(SimStruct *S){}
#ifdef MATLAB_MEX_FILE
#include "simulink.c"
#else
#include "cg_sfun.h"
#endif
0 Kommentare
Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!