matlab程序出错,请各位帮找一下原因format compactx=linspace(-2,8);f=x.^5-4*x.^4+3*x.^2-2*x+6+x.*sin(x);y1=zeros(size(x));plot(x,f)hold onplot(x,y1,'r')x1=solve('x^5-4*x^4+3*x^2-2*x+6+x*sin(x)','x')text(x1,0,'1.42688')运行后:x1 =1.4268
来源:学生作业帮助网 编辑:作业帮 时间:2024/08/25 20:43:00
![matlab程序出错,请各位帮找一下原因format compactx=linspace(-2,8);f=x.^5-4*x.^4+3*x.^2-2*x+6+x.*sin(x);y1=zeros(size(x));plot(x,f)hold onplot(x,y1,'r')x1=solve('x^5-4*x^4+3*x^2-2*x+6+x*sin(x)','x')text(x1,0,'1.42688')运行后:x1 =1.4268](/uploads/image/z/472508-44-8.jpg?t=matlab%E7%A8%8B%E5%BA%8F%E5%87%BA%E9%94%99%2C%E8%AF%B7%E5%90%84%E4%BD%8D%E5%B8%AE%E6%89%BE%E4%B8%80%E4%B8%8B%E5%8E%9F%E5%9B%A0format+compactx%3Dlinspace%28-2%2C8%29%3Bf%3Dx.%5E5-4%2Ax.%5E4%2B3%2Ax.%5E2-2%2Ax%2B6%2Bx.%2Asin%28x%29%3By1%3Dzeros%28size%28x%29%29%3Bplot%28x%2Cf%29hold+onplot%28x%2Cy1%2C%27r%27%29x1%3Dsolve%28%27x%5E5-4%2Ax%5E4%2B3%2Ax%5E2-2%2Ax%2B6%2Bx%2Asin%28x%29%27%2C%27x%27%29text%28x1%2C0%2C%271.42688%27%29%E8%BF%90%E8%A1%8C%E5%90%8E%EF%BC%9Ax1+%3D1.4268)
matlab程序出错,请各位帮找一下原因format compactx=linspace(-2,8);f=x.^5-4*x.^4+3*x.^2-2*x+6+x.*sin(x);y1=zeros(size(x));plot(x,f)hold onplot(x,y1,'r')x1=solve('x^5-4*x^4+3*x^2-2*x+6+x*sin(x)','x')text(x1,0,'1.42688')运行后:x1 =1.4268
matlab程序出错,请各位帮找一下原因
format compact
x=linspace(-2,8);
f=x.^5-4*x.^4+3*x.^2-2*x+6+x.*sin(x);
y1=zeros(size(x));
plot(x,f)
hold on
plot(x,y1,'r')
x1=solve('x^5-4*x^4+3*x^2-2*x+6+x*sin(x)','x')
text(x1,0,'1.42688')
运行后:
x1 =
1.426886968350643228428394466109
Error using text
Invalid parameter/value pair arguments
Error in main822 (line 9)
text(x1,0,'1.42688')
matlab程序出错,请各位帮找一下原因format compactx=linspace(-2,8);f=x.^5-4*x.^4+3*x.^2-2*x+6+x.*sin(x);y1=zeros(size(x));plot(x,f)hold onplot(x,y1,'r')x1=solve('x^5-4*x^4+3*x^2-2*x+6+x*sin(x)','x')text(x1,0,'1.42688')运行后:x1 =1.4268
x解出来竟然还是个复数,你x是符号型的,直接text会出错,为什么不用数值解呢,而且你都知道解释1.42688了,何必多此一举呢,顺便说一下,更精确的解是1.42689
x=linspace(-2,8);
f=x.^5-4*x.^4+3*x.^2-2*x+6+x.*sin(x);
y1=zeros(size(x));
plot(x,f)
hold on
plot(x,y1,'r')
x1=fsolve(@(x)x.^5-4*x.^4+3*x.^2-2*x+6+x.*sin(x),1)
text(x1,0,num2str(x1,6))