matlab中的取整问题,求大虾总是出现?Error using ==> roundFunction 'round' is not defined for values of class 'sym'.我是想用一条多项式拟合出的曲线与另外多条的交点以向量形式输出,且取整.源程序:clearx1=[10

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/29 23:51:00

matlab中的取整问题,求大虾总是出现?Error using ==> roundFunction 'round' is not defined for values of class 'sym'.我是想用一条多项式拟合出的曲线与另外多条的交点以向量形式输出,且取整.源程序:clearx1=[10
matlab中的取整问题,求大虾
总是出现?Error using ==> round
Function 'round' is not defined for values of class 'sym'.
我是想用一条多项式拟合出的曲线与另外多条的交点以向量形式输出,且取整.
源程序:
clear
x1=[1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 2100 2200];
y1=[748.0 757.0 762.8 764.0 759.0 754.6 749.0 740.0 730.0 718.0 704.0 691.0 664.0];
p1=polyfit(x1,y1,3)
x2=[0.000 0.101 0.200 0.301 0.404 0.456 0.600 0.699 0.799 0.900 0.936 0.993];
y2=[27.6 27.6 27.3 26.9 26.2 25.6 23.9 22.4 20.5 15.6 12.3 4.2];
p2=polyfit(x2,y2,9)
for m=1:10;
k=m*0.1;
g=9.8;
D=0.356;
y3=polyval(p2,k);
x4=1000:100:2200;
y4=y3*g*D^5*x4.^2*0.0001;
p3=polyfit(x4,y4,3);
f1=poly2sym(p1);
f2=poly2sym(p3);
F=f1-f2;
x=solve(F);
q=x(3)
t=real(q);
r(m)=t;
end
r(1:10)
vpa(r,9)
k=0.1:0.1:1;
x5=r.*k
h=x5(1:10)
h2=round(h)

matlab中的取整问题,求大虾总是出现?Error using ==> roundFunction 'round' is not defined for values of class 'sym'.我是想用一条多项式拟合出的曲线与另外多条的交点以向量形式输出,且取整.源程序:clearx1=[10
h的类型不符合round,在round之前h=double(h);,把h改为double型