MATLAB Answers


Problem in using Fsolve in Simulink

Asked by Krishna
on 1 Aug 2013

I am trying to use 'fsolve' in Simulink, and I found the following thread on Mathworks:

I used the same technique as 'Kaustubha Govind' mentioned for a model I am trying to design in Simulink, and I am running into more errors. To give a basic idea about what I am trying to do, I have the following structure. I am using the 'Interpreted Matlab Function' block in Simulink.


Here, x0 is a 1 X 12 matrix and u(1)..,u(16) are scalars. 'sample' is a function (m-file) that I have saved in the Matlab folder. To start with, Have I framed the 'Interpreted Matlab function' properly?

After I run this model, I get the following errors:

1) Error in 'Model/Subsystem/Interpreted MATLAB Function' while evaluating expression.

2) Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue.

3) Too many output arguments.


  1 Comment

Kaustubha Govind
on 12 Aug 2013

Hi Krishna,

Please avoid sending personal messages, since all forum users participate in their leisure time and are not mandated to do so as an order of business.

Here are some resources that might help with unanswered questions:

If your license is on maintenance, please also note that you may contact MathWorks Tech Support as an alternate resource for urgent issues:

Thank you for your consideration!

1 Answer

Answer by Kaustubha Govind
on 12 Aug 2013

Are you able to run fsolve with similar input arguments (as passed in from the Interpreted MATLAB Function block) outside of Simulink? Please set a breakpoint in your S-function code to ensure that the inputs are passed in correctly.

  1 Comment

on 12 Aug 2013

Yes, I am able to run fsolve with similar input arguments outside of Simulink. I am not using a S-function in my model, could you clarify what you are referring to with respect to setting a breakpoint in the S-function code?

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!