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/11/09 10:08:39
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尽管找我 .这么简单的都不会,真笨!