clear all;
syms x
y = (1500-x)*(1+0.0015*x);
ezplot(y,[1000,2000]);
dydx = diff(y,x);
xsh= solve(dydx);
ymax=subs(y,x,xsh);
ezplot(y,[0 1500]) ;
hold on;
plot(xsh,ymax,'-ro');
grid on;
hold off;
fprintf('the best count is %d dollars/n',xsh)
运行后
??? Error using ==> fprintf
Function is not defined for 'sym' inputs.
Error in ==> one1 at 13
fprintf('the best count is %d dollars/n',xsh)
求解释
|