函数或变量 'poly2str' 无法识别,如何导入poly2str?
Afficher commentaires plus anciens
x=-2*pi:pi/2:2*pi;
y=[1,0,-1,0,1,0,-1,0,1];
p2=polyfit(x,y,2);
p3=polyfit(x,y,3);
p4=polyfit(x,y,4);
p6=polyfit(x,y,6);
disp('二次拟合函数'),f2=poly2str(p2,'x');
disp('三次拟合函数'),f3=poly2str(p3,'x');
disp('四次拟合函数'),f4=poly2str(p4,'x');
disp('七次拟合函数'),f6=poly2str(p6,'x');
x1=-2*pi:pi/10:2*pi;
y2=polyval(p2,x1);
y3=polyval(p3,x1);
y4=polyval(p4,x1);
y6=polyval(p6,x1);
yy=cos(x1);
plot(x,y,x1,y2,'-b',x1,y3,'-.r',x1,y4,'*c',x1,y6,'.g',x1,yy);
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur 安装和许可简介 dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!