hilbert曲线序编码matlab,[转载]希尔伯特曲线及其matlab画法

基本概念:

希尔伯特曲线是一种能填充满一个平面正方形的分形曲线(空间填充曲线),由大卫·希尔伯特在1891年提出。由于它能填满平面,它的豪斯多夫维是2。取它填充的正方形的边长为1,第n步的希尔伯特曲线的长度是2n

- 2-n。

L系统记法:

变量: L, R

常数: F, +, - (F:向前,-:右转90°,+:左转90°)

公理: L

规则:L → +RF-LFL-FR+   R → LF+RFR+FL

用matlab画希尔伯特曲线的程序:

function [x,y] = hilbert(n)

%HILBERT Hilbert curve.

%source:http://www.mathworks.com/matlabcentral/fileexchange/4646,2010.11.20

% [x,y]=hilbert(n) gives the vector coordinates of points

% in n-th order Hilbert curve

of area 1.

% Example: plot of 5-th order curve

% [x,y]=hilbert(5);line(x,y)

% Copyright (c) by Federico

Forte

% Date: 2000/10/06

if n<=0

x=0;

y=0;

else

[xo,yo]=hilbert(n-1);

x=.5*[-.5+yo -.5+xo .5+xo .5-yo];

y=.5*[-.5+xo .5+yo .5+yo

-.5-xo];

end

程序的运行:

[x,y]=hilbert(1);subplot(3,3,1),line(x,y)

[x,y]=hilbert(2);subplot(3,3,2),line(x,y)

[x,y]=hilbert(3);subplot(3,3,3),line(x,y)

[x,y]=hilbert(4);subplot(3,3,4),line(x,y)

[x,y]=hilbert(5);subplot(3,3,5),line(x,y)

[x,y]=hilbert(6);subplot(3,3,6),line(x,y)

[x,y]=hilbert(7);subplot(3,3,7),line(x,y)

[x,y]=hilbert(7);subplot(3,3,8),line(x,y)

[x,y]=hilbert(8);subplot(3,3,9),line(x,y)

画出的图像:

a4c26d1e5885305701be709a3d33442f.png

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值