matlab多项式画图

来源:百度知道 编辑:UC知道 时间:2024/06/15 20:26:41
已知多项式为y=1.4017*10^(1/24)*x^10-8.0132*10^(1/21)*x^9+1.96*10^(1/17)*x^8-2.6776*10^(1/14)*x^7+2.2366*10^(1/11)*x^6-1.1746*10^(1/8)*x^5+3.8326*10^(1/6)*x^4-0.0007347*x^3+0.072265*x^2-2.5331*x+25.817,x的取值范围是0到1080.
编码:
x=1:5:1080;
y=1.4017*10^(1/24)*x^10-8.0132*10^(1/21)*x^9+1.96*10^(1/17)*x^8-2.6776*10^(1/14)*x^7+2.2366*10^(1/11)*x^6-1.1746*10^(1/8)*x^5+3.8326*10^(1/6)*x^4-0.0007347*x^3+0.072265*x^2-2.5331*x+25.817;
plot(x,y);

错误是:
??? y=1.4017*10^(1/24)*x^10-8.0132*10^(1/21)*x^9+1.96*10^(1/17)*x^8-2.6776*10^(1/14)*x^7+2.2366*10^(1/11)*x^6-1.1746*10^(1/8)*x^5+3.8326*10^(1/6)*x^4-0.0007347*x^3+0.072265*x^2-2.5331*x+25.817;
|
Error: Missing variable or function.
请问如何改正

用手工加点太麻烦了,还容易出错,最好用函数:

clc;clear
x=1:5:1080;
y='1.4017*10^(1/24)*x^10-8.0132*10^(1/21)*x^9+1.96*10^(1/17)*x^8-2.6776*10^(1/14)*x^7+2.2366*10^(1/11)*x^6-1.1746*10^(1/8)*x^5+3.8326*10^(1/6)*x^4-0.0007347*x^3+0.072265*x^2-2.5331*x+25.817';
y=vectorize(y)
y=eval(y);
plot(x,y);

结果:
y =

1.4017.*10.^(1./24).*x.^10-8.0132.*10.^(1./21).*x.^9+1.96.*10.^(1./17).*x.^8-2.6776.*10.^(1./14).*x.^7+2.2366.*10.^(1./11).*x.^6-1.1746.*10.^(1./8).*x.^5+3.8326.*10.^(1./6).*x.^4-0.0007347.*x.^3+0.072265.*x.^2-2.5331.*x+25.817

x=1:5:1080;
y=1.4017*10^(1/24)*x.^10-8.0132*10^(1/21)*x.^9+1.96*10^(1/17)*x.^8-2.6776*10^(1/14)*x.^7+2.2366*10^(1/11)*x.^6-1.1746*10^(1/8)*x.^5+3.8326*10^(1/6)*x.^4-0.0007347*x.^3+0.072265*x.^2-2.5331*x+25.817;
plot(x,y);
就是像上面这样的,x^10要改为x.^10,还有一个问题,Missing variable or function,是因为你的第一个括号的右括号不是英文输入状态下的,这一样会得不出结果

已修正

x=1:5:1080;

y=1.4017 .* 10^(1/24) .*