^.^ - http://goo.gl/GDIO
Labels
acm
c++
euler
firefox
matlab
opencv
opengl
Programming
python
pythonlib
ubuntu
22 Jun 2010
matlab生成螺旋矩阵
Email This
BlogThis!
Share to Twitter
Share to Facebook
Share to Pinterest
n=5;
a=rand(1,n);
b=a(bsxfun(@(i,j)i+j-1-n*(i+j>n+1),1:n,(1:n)'))
产生一个螺旋型n*n矩阵,如:n=5时:
1 2 3 4 5
16 17 18 19 6
15 24 25 20 7
14 23 22 21 8
13 12 11 10 9
No comments :
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments ( Atom )
No comments :
Post a Comment