Errors with fmincon in Matlab script
Show older comments
I get these errors when I try to run my script. Any suggestions? The meshgrid section of code runs fine.
Not enough input arguments.
Error in HW5_fmincon>system2 (line 20)
x3 = 3*sin(x1.*x2)./(1+x1.^2);
Error in HW5_fmincon (line 12)
[x,fval] = fmincon(system2,[2;3.5],[],[],[],[],[1;2],[3;5])
------------------------------------------------------------------------------------------------------------------------------------------------
clear
clc
% Use fmincon to find the minimum values of x(1) and x(2) that will
% satisfy function system2 below
% Initial guess is x(1) = 2 and x(2) = 3.5
% Subject to the following constraints:
% 1<=x(1)<=3 and 2<=x(2)<=5
[x,fval] = fmincon(system2,[2;3.5],[],[],[],[],[1;2],[3;5])
% Create 3D plot using x(1) and x(2) between -4 and 4 in 0.2 increments
[a,b]=meshgrid(-4:0.2:4);
fx=system2(a,b);
mesh(a,b,fx)
function x3 = system2(x1,x2)
x3 = 3*sin(x1.*x2)./(1+x1.^2);
end
Accepted Answer
More Answers (0)
Categories
Find more on Choose a Solver 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!