作业帮 > 数学 > 作业

如何用matlab绘制贝塞尔曲线

来源:学生作业帮 编辑:作业帮 分类:数学作业 时间:2024/11/09 06:00:39
如何用matlab绘制贝塞尔曲线
10阶贝塞尔曲线(平面曲线)
,控制点分别为
(0,1.2),(0.04,0.6),(0.15,0.51),(0.32,0.88),
(0.31,0.09),(0.52,0),(0.62,0.8),(0.89,0.87),(0.92,0.6),(0.92,0.3),
(0.75,0).
以下是运行结果:程序代码:function bezier(x,y) x=[0,0.04,0.15,0.32,0.31,0.52,0.62,0.89,0.92,0.75]; y=[1.2,0.6,0.51,0.88,0.09,0,0.8,0.87,0.6,0.3,0];n=length(x);t=linspace(0,1);xx=0;yy=0;for k=0:n-1    tmp=nchoosek(n-1,k)*t.^k.*(1-t).^(n-1-k);    xx=xx+tmp*x(k+1);    yy=yy+tmp*y(k+1);endif nargout==2    X=xx;Y=yy;endh=plot(xx,yy);if nargout==1    X=h;