MATLAB: Am I getting error running the sensorless_MRAS.mdl model from FileExchange in the Simulink R2011b environment

sfun_spssw_contcsimpowerSimscape Electrical

I downloaded an example model from FileExchange: <https://www.mathworks.com/matlabcentral/fileexchange/27970-sensorless-model-of-permanent-magnet-synchronous-motor>. 
I tried to simulate this model in MATLAB/Simulink R2011b. 
However, I got the following error: 
"For S-function 'sfun_spssw_contc', the number of defined parameters, 10, does not match the number of parameters on the dialog of 'sensorless_MRAS/powergui/EquivalentModel1/State-Space', 9. These two values must be identical."
How do I fix this?

Best Answer

The example file was found to be in version '1.209' (Simulink 6.3 or R14SP3).
Changes could have happened between R14SP3 and R2011b so the 'sfun_spssw_contc' S-function takes 1 more parameter now.
Now, the 'sfun_spssw_contc' S-function takes 10 parameters, as indicated below:
 
* Index Symbolic Name Description
* ------ -------------------- ---------------------------------------------------
* 0 A_PARAM A,B,C,D: Continuous state space matrices of
* 1 B_PARAM electrical system (all switches open).
* 2 C_PARAM
* 3 D_PARAM
* 4 XO_PARAM Vector (1,NSTATES) of initial values of states.
* 5 EnableUseOfTLC_PARAM Enable the use of the TLC with the accelarator.
*
* The following parameters are omitted when switch count is 0.
*
* 6 RS_PARAM Vector (1,NSWITCH) of switch resistances
* in the closed state
* 7 SWT_PARAM Vector (1,NSWITCH) of switch types :
* 1 : Ideal switch
* 2 : Circuit breaker (closes on demand;
* opens at zero crossing current)
* 3 : Diode ; closes if V>0 Opens if I<0
* 4 : Thyristor
* 5 : GTO
* 6 : IBGT
* 7 : IBGT/diode pair or MOSFET with internal diode
*
* 8 GIV_PARAM Vector (1,NSWITCH) of switches gates initial values
* (0.0 or 1.0)
*
* 9 YISW_PARAM Vector (1,NSWITCH) of switch current
* measure indexes (Indexes in output vector).
* The output current of the corresponding
* switches will forced to '0' when the switches
* are open. A zero index means a zero current
* is not imposed on that particular switch
* when open.
The example model is missing parameter 5 (EnableUseOfTLC_PARAM). Please add this parameter (0 or 1) after 'x0' in the dialog box of the S-function block to resolve the issue.