MATLAB: Error message in Simulink

simulink

Hi,Help please,when i try to run my Simulink model, i obtain this error:
when i use ode45 solver:State derivatives returned by S-function 'reactor_sfcn' in 'reactor_simulink_Left1/S-Function' during flag=1 call must be a real vector of length 2
when i use ode15s solver:Nonlinear iteration is not converging with step size reduced to hmin (1.5009766490884663E-14) at time 4.2248736734541605. Try reducing the minimum step size and/or relax the relative error tolerance
I thought this error related to my solver in simulink,then i changed it but not corrected!!! please help!!!

Best Answer

First, I think you should tackle the error that you see with the ODE45 solver - it looks like there is a problem with your S-function. How are you returning the derivatives of the states in flag=1 case? It seems that you have setup for 2 continuous states, so you need to return a vector of length 2 from mdlDerivatives (flag=1).
Related Question