Use S-Function parameters from dialog box
3 views (last 30 days)
Show older comments
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 Comments
Answers (0)
See Also
Categories
Find more on Simulink Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!