I get an error using fminsearch and says Simulink model "model ex3" was called with incorrect number of arguments. I have attached a picture to show it.

3 views (last 30 days)
I get an error using fminsearch and says Simulink model "model ex3" was called with incorrect number of arguments. I have attached a picture to show it.
  1 Comment
Paul
Paul on 3 Mar 2024
Edited: Paul on 5 Mar 2024
Calling a model programatically like that is not typically used for most applications. Also, the inputs to and outputs from the model called as a function is not the interface required by fminsearch, so some more function wrapping would be needed.
Can you shed more insight into exactly what you're trying to do with that model within fminsearch? For example, are you trying to use fminearch to find some model parameters that minimize a scalar figure of merit derived from simulating the model?

Sign in to comment.

Answers (1)

Torsten
Torsten on 3 Mar 2024
Edited: Torsten on 3 Mar 2024
Try calling fminsearch as
[xSolution,fval] = fminsearch(@(x)model_ex3(x,par),x0)
If this doesn't work, we need to know the inputs expected for model_ex3.
  1 Comment
Walter Roberson
Walter Roberson on 3 Mar 2024
I wonder whether the model is constructed to have inputs at all? Might need to write a wrapper function that does something similar to assignin('base', 'SomeVariable', x) and then invoking model_ex3

Sign in to comment.

Categories

Find more on Modeling in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!