matlab画出雪花曲线function y=koch(x1,x2,y1,y2,n)if n>1koch(x1,y1,(2*x1+x2)/3,(2*y1+y2)/3,n-1);koch((2*x1+x2)/3,(2*y1+y2)/3,(x1+x2)/2+(y1-...y2)*sqrt(3)/6,(y1+y2)/2+(x2-x1)*sqrt(3)/6,n-1);koch((x1+x2)/2+(y1-y2)*sqrt(3)/6,(y1+y2)/2+(x2-...x1)*sqr

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/18 15:43:39
matlab画出雪花曲线functiony=koch(x1,x2,y1,y2,n)ifn>1koch(x1,y1,(2*x1+x2)/3,(2*y1+y2)/3,n-1);koch((2*x1+x2)

matlab画出雪花曲线function y=koch(x1,x2,y1,y2,n)if n>1koch(x1,y1,(2*x1+x2)/3,(2*y1+y2)/3,n-1);koch((2*x1+x2)/3,(2*y1+y2)/3,(x1+x2)/2+(y1-...y2)*sqrt(3)/6,(y1+y2)/2+(x2-x1)*sqrt(3)/6,n-1);koch((x1+x2)/2+(y1-y2)*sqrt(3)/6,(y1+y2)/2+(x2-...x1)*sqr
matlab画出雪花曲线
function y=koch(x1,x2,y1,y2,n)
if n>1
koch(x1,y1,(2*x1+x2)/3,(2*y1+y2)/3,n-1);
koch((2*x1+x2)/3,(2*y1+y2)/3,(x1+x2)/2+(y1-...
y2)*sqrt(3)/6,(y1+y2)/2+(x2-x1)*sqrt(3)/6,n-1);
koch((x1+x2)/2+(y1-y2)*sqrt(3)/6,(y1+y2)/2+(x2-...
x1)*sqrt(3)/6),(2*x2+x1)/3,(2*y2+y1)/3,n-1);
koch(2*x2+x1)/3,(2*y2+y1)/3,x2,y2,n-1);
else
x=[x1,(2*x1+x2)/3,(x1+x2)/2+(y1-...
y2)*sqrt(3)/6,2*x2+x1)/3,x2];
y=[y1,(2*y1+y2)/3,(y1+y2)/2+(x2-...
x1)*sqrt(3)/6,2*y2+y1)/3,y2];
line(x,y)
end
axis equal
title('雪花曲线')
运行之后有
function y=koch(x1,x2,y1,y2,n)
|
Error:Function definitions are not permitted in
this context.
保存为M文件后,调用 koch(0,0,1,0,5)
Error:File:koch.m Line:7 Column:51
Unbalanced or unexpected parenthesis or bracket.

matlab画出雪花曲线function y=koch(x1,x2,y1,y2,n)if n>1koch(x1,y1,(2*x1+x2)/3,(2*y1+y2)/3,n-1);koch((2*x1+x2)/3,(2*y1+y2)/3,(x1+x2)/2+(y1-...y2)*sqrt(3)/6,(y1+y2)/2+(x2-x1)*sqrt(3)/6,n-1);koch((x1+x2)/2+(y1-y2)*sqrt(3)/6,(y1+y2)/2+(x2-...x1)*sqr
具体方案已经发给你发给你个人资料填写的邮箱了,以后有什么matlab尽管找我 .这么简单的都不会,真笨!