举个例子:m1 = 1; n1 = 2; n2 = 3; m0 = 4; c = 5; n0 = 6; r = 7;myfun = @(x) (m1*(n1+n2)+m0*c*x(1)/x(2)+r*x(1)*x(2)*n1+r*n0*x(1)^2/2);x0 = [1 1];[x,fval] = fminunc(myfun,x0);clc;xfval