Use S-Function parameters from dialog box
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I have created S-Functions with mdlCheckParameters method. I can insert into dialog box numbers in range (0;Inf). How can I configure mdlCheckParameters to inserting negative and decimal numbers into dialog box?
Here is mdlCheckParameters code:
#define MDL_CHECK_PARAMETERS
#if defined(MDL_CHECK_PARAMETERS) && defined(MATLAB_MEX_FILE)
/* Function: mdlCheckParameters =============================================
* Abstract:
* Validate that the parameter is a positive finite integer scalar
*/
static void mdlCheckParameters(SimStruct *S)
{
int ival;
bool badParam = false;
/* All parameters must be positive non-zero integers */
const mxArray *m = ssGetSFcnParam(S,0);
if (mxGetNumberOfElements(m) != 1 ||
!mxIsNumeric(m) || !mxIsDouble(m) || mxIsLogical(m) ||
mxIsComplex(m) || mxIsSparse(m) || !mxIsFinite(mxGetPr(m)[0])) {
badParam = true;
} else if (((ival=(int_T)mxGetPr(m)[0]) <= 0) ||
(real_T)ival != mxGetPr(m)[0]) {
badParam = true;
}
if (badParam) {
ssSetErrorStatus(S,"The parameter must be a positive non-zero "
"integer value.");
return;
}
}
#endif /* MDL_CHECK_PARAMETERS */
Thanks!
Vit
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Simulink Functions 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!