发布网友
共2个回答
热心网友
而广告费与销售量成二次多项式(抛物线关系)关系
Linear model Poly2:
f(x) = p1*x^2 + p2*x + p3
Coefficients (with 95% confidence bounds):
p1 = -0.0004256 (-0.0004701, -0.0003811)
p2 = 0.04092 (0.03768, 0.04416)
p3 = 1.019 (0.9702, 1.067)
Goodness of fit:
SSE: 0.002515
R-square: 0.997
Adjusted R-square: 0.9957
RMSE: 0.02243
价格与售出量成线性关系,
Linear model Poly1:
f(x) = p1*x + p2
Coefficients (with 95% confidence bounds):
p1 = -5.133 (-5.573, -4.694)
p2 = 50.42 (48.58, 52.27)
Goodness of fit:
SSE: 3.622
R-square: 0.9909
Adjusted R-square: 0.96
RMSE: 0.7193
使用非线性规划求解,建立函数文件存为Xno.m
function [f,g]=Xno(x)
x1=[0 10 20 30 40 50 60 70];
y1=[1.0 1.40 1.70 1.85 1.95 2.00 1.95 1.80];
x2=[2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0];
y2=[41,38,34,32,29,28,25,22,20];
a=polyfit(x1,y1,2);
b=polyfit(x2,y2,1);
f=-(x(2)-2)*polyval(b,x(2))*polyval(a,x(1))+x(1)
g(1)=x(1)-70;
g(2)=x(2)-6;
g(3)=-x(1);
g(4)=-x(2)+2;
在命令窗口输入
x0=[30 3];opt(1)=1;
>> x=constr('Xno',x0,opt)
可得广告费和价格。
x =
33.1166 5.9113
热心网友
x=[2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0];
y=[41000 38000 34000 32000 29000 28000 25000 22000 20000];
ady=[0 10000 20000 30000 40000 50000 60000 70000];
r=[1.0 1.40 1.70 1.85 1.95 2.00 1.95 1.80 ];
for i=1:9
for j=1:8
if j==1
p(i,j)=x(i)*y(i);
else
p(i,j)=x(i)*(y(i)*r(j))-ady(j);
end
end
end
maxp=max(max(p));%最大利润
[maxX,maxY]=find(p==maxp);
X=x(maxX);%每桶价钱
Y=ady(maxY);%投入的广告费