Use S-Function parameters from dialog box
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/191892/image.png)
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 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Simulink Functions en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!