Use S-Function parameters from dialog box

3 次查看(过去 30 天)
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 个)

类别

Help CenterFile Exchange 中查找有关 Simulink Functions 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by