Matlab Coder and fminsearch

5 次查看(过去 30 天)
Arwel
Arwel 2018-4-13
Hi,
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???
Cheers,
Arwel

回答(1 个)

Steven Lord
Steven Lord 2018-4-13
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.

类别

Help CenterFile Exchange 中查找有关 MATLAB Coder 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by