MATLAB XPC TARGET RELEASE NOTES Guía de usuario Pagina 249

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 531
  • Tabla de contenidos
  • SOLUCIÓN DE PROBLEMAS
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 248
Step-by-Step Example of Fortran and xPC Target™
ssSetOutputPortWidth(S, 1, 3); /* pressure */
ssSetOutputPortWidth(S, 2, 3); /* density */
#if de fined(MATLAB_MEX_FILE)
EXIT_POINT:
#endif
return;
}
10 Use the mdlInitializeSamp leTimes callback to specif y th e sample rates
at which this S-function operates.
static void mdlInitializeSampleTimes(SimStruct *S)
{
ssSetSampleTime(S, 0, INHERITED_SAMPLE_TIME);
ssSetOffsetTime(S, 0, 0.0);
ssSetModelReferenceSampleTimeDefaultInheritance(S);
}
11 Use the mdlOutp uts callback to compute the signals that this block emits.
static void mdlOutputs(SimStruct *S, int_T tid)
{
double *alt = (double *) ssGetInputPortSignal(S,0);
double *T = (double *) ssGetOutputPortRealSignal(S,0);
double *P = (double *) ssGetOutputPortRealSignal(S,1);
double *rho = (double *) ssGetOutputPortRealSignal(S,2);
int w = ssGetInputPortWidth( S,0);
int k;
float falt, fsigma, fdelta, ftheta;
for (k=0; k<w; k++) {
/* set the input value */
falt = (float) alt[k];
/* call the Fortran routine using pass-by-reference */
atmos_(&falt, &fsigma, &fdelta, &ftheta);
/* format the outputs using the reference parameters */
T[k] = mxGetScalar(T0(S)) * (double) ftheta;
13-11
Vista de pagina 248
1 2 ... 244 245 246 247 248 249 250 251 252 253 254 ... 530 531

Comentarios a estos manuales

Sin comentarios