Matlab Coder and fminsearch
4 views (last 30 days)
Show older comments
Arwel on 13 Apr 2018
Answered: Steven Lord on 13 Apr 2018
I am trying to compile an application which uses fminsearch using Matlab Coder. In the documentation for coder it suggests that fminsearch is suitable for code generation. However, when I try to compile I get errors like the following....
"Size mismatch (size [1 x 15] ~= size [1 x 6]). The size to the left is the size of the left-hand side of the assignment."
When I check the relevant line, it's falling over here.....
if fxe < fxr
v(:,end) = xe;
fv(:,end) = fxe;
how = 'expand';
...basically at the how = 'expand'; line. Looking at the subsequent errors, it's also complaining about subsequent setting of 'how' like this.....
Size mismatch (size [1 x 15] ~= size [1 x 16]). The size to the left is the size of the left-hand side of the assignment.
when it tries...
how = 'contract inside'
and so on.... So obviously it doesn't like the fact that 'how' keeps changing size. If fminsearch is meant to be suited for codegen, why is it throwing this error???
Steven Lord on 13 Apr 2018
Which release of MATLAB are you using? If you're using a release prior to release R2014a when support for code generation from fminsearch was introduced, that may be the cause of the error you received.
Find more on Algorithm Design Basics 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!