MATLAB程序运行不出结果v=14;g=10;L1=0.6;L2=0.6;R = @(x) -(v*sin(x(2))*(g*v*cos(x(2))+sqrt(g^2*v^2^cos(x(2))^2+2*L1*g*sin(x(1))+2*L2*g*sin(x(2)))));lb = [20; 20]; % x y的下限ub = [45; 90] ; % x y的上限x0 = [30;60]; % Starting guess at the
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/15 21:05:13
MATLAB程序运行不出结果v=14;g=10;L1=0.6;L2=0.6;R = @(x) -(v*sin(x(2))*(g*v*cos(x(2))+sqrt(g^2*v^2^cos(x(2))^2+2*L1*g*sin(x(1))+2*L2*g*sin(x(2)))));lb = [20; 20]; % x y的下限ub = [45; 90] ; % x y的上限x0 = [30;60]; % Starting guess at the
MATLAB程序运行不出结果
v=14;
g=10;
L1=0.6;
L2=0.6;
R = @(x) -(v*sin(x(2))*(g*v*cos(x(2))+sqrt(g^2*v^2^cos(x(2))^2+2*L1*g*sin(x(1))+2*L2*g*sin(x(2)))));
lb = [20; 20]; % x y的下限
ub = [45; 90] ; % x y的上限
x0 = [30;60]; % Starting guess at the solution
[x1,fval1] = fmincon(R,x0,[],[],[],[],lb,ub);
xmax2 = x1(1) % 极值点x的值
ymax2 = x1(2) % 极值点y的值
zmax2 = -fval1 % Z的最大值
这个是源程序
运行后提示
Warning:To use the default trust-region-reflective algorithm you must supply the gradient in the
objective function and set the GradObj option to 'on'.FMINCON will use the active-set algorithm instead.
For information on applicable algorithms,see Choosing the Algorithm in the documentation.
MATLAB程序运行不出结果v=14;g=10;L1=0.6;L2=0.6;R = @(x) -(v*sin(x(2))*(g*v*cos(x(2))+sqrt(g^2*v^2^cos(x(2))^2+2*L1*g*sin(x(1))+2*L2*g*sin(x(2)))));lb = [20; 20]; % x y的下限ub = [45; 90] ; % x y的上限x0 = [30;60]; % Starting guess at the
计算有结果啊!~
xmax2 =
30.0376 + 0.2358i
ymax2 =
63.2612 - 0.1850i
zmax2 =
9.2040e+003 -1.3470e+000i