How to pass a structure parameter in simulink mask to C mex S-Function?
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello everyone,
I am using C mex S-Function to simulate in simulink and want to pass a structure parameter in Initialization Commands of Mask Editor to it.The structure parameter is here, e.g.:
CtrlPara.Kvp = 0.2;
CtrlPara.Kvi = 10 ;
CtrlPara.Kip = 0.1;
CtrlPara.Kii = 0 ;
I want C mex S-Function to access the parameter Kvp.Kvi,Kip and Kii. I found two commands,which may be helpful.They are following:
ssGetSFcnParam
mxGetField
0 comentarios
Respuestas (1)
Lucas Lebert
el 4 de Jul. de 2018
Hi Huadian!
I think you already have most of the information! In the mdlInitializeSizes callback method you need to set the Number of SFcnParameters,e.g: ssSetNumSFcnParams(S, 1);
Depending on where you want to use the fields of the Structure you can access these with the commands you mentioned, e.g:
const mxArray *param = mxGetField(ssGetSFcnParam(S,0),0,"Kvp");
real_T *value = mxGetPr(param);
Now you can use the pointer value for your further calculations.
Thanks! ~Lucas
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!