Issue with MATLAB App Designer and Undefined Function Error
古いコメントを表示
Hi everyone,
I hope you're all doing well. I'm currently facing an issue with my MATLAB App Designer project, and I was hoping to get some assistance.
I'm using the MATLAB App Designer to create an app, and I have a set of three .m files - myfun.m, constraints.m, and optimize.m. The optimize.m file is a function file containing the following code:
function [x, fval, exitflag, output, lambda, grad, hessian] = optimize(x0)
options = optimoptions('ga');
%% Modify options setting
options = optimoptions(options, 'Display', 'off');
options = optimoptions(options, 'PlotFcn', { @optimplotx @optimplotfunccount @optimplotfval @optimplotconstrviolation @optimplotstepsize @optimplotfirstorderopt });
[x, fval, exitflag, output, lambda, grad, hessian] = ...
fmincon(@myfun, x0, [], [], [], [], [], [], @constraints, options);
In my App Designer, I have set up multiple EditFields and a button. Under the button, I use the following code:
% Button pushed function: OptimizeButton
function OptimizeButtonPushed(app, event)
z(1) = str2double(app.EditField1.Value);
z(2) = str2double(app.EditField2.Value);
z(3) = str2double(app.EditField3.Value);
z(4) = str2double(app.EditField4.Value);
z(5) = str2double(app.EditField5.Value);
z(6) = str2double(app.EditField6.Value);
z(7) = str2double(app.EditField7.Value);
z(8) = str2double(app.EditField8.Value);
x0 = [z(1) z(2) z(3) z(4) z(5) z(6) z(7) z(8)];
[x, fval, exitflag, output, lambda, grad, hessian] = optimize(x0);
end
However, when I run the app and click on "Optimize" Button, it stops and shows "Undefined function 'optimize' for input arguments of type 'double.'"
I've made sure that all three .m files and the app design file are in the same directory. Can anyone help me figure out what might be causing this issue?
Thank you in advance for your assistance!
Best regards.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Develop Apps Using App Designer についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!