已知函数为f(x)=x^3-3*x^2-x+3,编辑函数文件 hanshu.m,计算f(0.3)、f(6.87)、f(3)-f(2)[f^2(-4)],并画出他的图形
函数文件 hanshu.m
function f=hanshu(x)
f=x.^3-3*x.^2-x+3;
end
f(0.3)、f(6.87)、f(3)-f(2)[f^2(-4)]的计算值
x=-10:0.5:10;y=hanshu(x);plot(x,y),xlabel('x'),ylabel('f(x)')
hanshu.m文件
另一个m文件
t = -5 : 0.01 : 5