Differences From Artifact [0ed4c539b6]:

To Artifact [3d56d803b8]:


102
103
104
105
106
107
108


109
110
111
112
113
114
115
  prhs[0] = P;
  
  mexCallMATLAB (1, plhs, 1, prhs, "<mtt_model_name>_state");  

  for (int i = 0; i < MTTNX; i++) {
    ssGetContStates (S)[i] = states [i];
  }


}

static void mdlOutputs(SimStruct *S, int_T tid)
{
  static mxArray *plhs[1];
  static mxArray *prhs[4];








>
>







102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
  prhs[0] = P;
  
  mexCallMATLAB (1, plhs, 1, prhs, "<mtt_model_name>_state");  

  for (int i = 0; i < MTTNX; i++) {
    ssGetContStates (S)[i] = states [i];
  }

  mxDestroyArray (plhs[0]);
}

static void mdlOutputs(SimStruct *S, int_T tid)
{
  static mxArray *plhs[1];
  static mxArray *prhs[4];

127
128
129
130
131
132
133


134
135
136
137
138
139
140

  mexCallMATLAB (1, plhs, 4, prhs, "<mtt_model_name>_odeo");
  double *outputs = mxGetPr (plhs[0]);

  for (int i = 0; i < MTTNY; i++) {
      ssGetOutputPortRealSignal (S,i)[0] = outputs [i];
  }


}

#define MDL_DERIVATIVES
static void mdlDerivatives(SimStruct *S)
{
  static mxArray *plhs[1];
  static mxArray *prhs[4];







>
>







129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144

  mexCallMATLAB (1, plhs, 4, prhs, "<mtt_model_name>_odeo");
  double *outputs = mxGetPr (plhs[0]);

  for (int i = 0; i < MTTNY; i++) {
      ssGetOutputPortRealSignal (S,i)[0] = outputs [i];
  }

  mxDestroyArray (plhs[0]);
}

#define MDL_DERIVATIVES
static void mdlDerivatives(SimStruct *S)
{
  static mxArray *plhs[1];
  static mxArray *prhs[4];
151
152
153
154
155
156
157


158
159
160
161
162
163
164
165
166
167
168
169

  mexCallMATLAB (1, plhs, 4, prhs, "<mtt_model_name>_ode");
  double *rates= mxGetPr (plhs[0]);
  
  for (int i = 0; i < MTTNX; i++) {
    ssGetdX (S)[i] = rates [i];
  }


}

static void mdlTerminate(SimStruct *S)
{
    UNUSED_ARG(S);
}

#ifdef  MATLAB_MEX_FILE    /* Is this file being compiled as a MEX-file? */
#include "simulink.c"      /* MEX-file interface mechanism */
#else
#include "cg_sfun.h"       /* Code generation registration function */
#endif







>
>












155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175

  mexCallMATLAB (1, plhs, 4, prhs, "<mtt_model_name>_ode");
  double *rates= mxGetPr (plhs[0]);
  
  for (int i = 0; i < MTTNX; i++) {
    ssGetdX (S)[i] = rates [i];
  }

  mxDestroyArray (plhs[0]);
}

static void mdlTerminate(SimStruct *S)
{
    UNUSED_ARG(S);
}

#ifdef  MATLAB_MEX_FILE    /* Is this file being compiled as a MEX-file? */
#include "simulink.c"      /* MEX-file interface mechanism */
#else
#include "cg_sfun.h"       /* Code generation registration function */
#endif

MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]