[Matlab] Grid renumbering for Matrix

1. Feb 21, 2013

qwuasi

1. The problem statement, all variables and given/known data

I have a matrix A $\in$ R$^{m x m}$ where m = n$^{2}$ and n = 2$^{k}$ +1, k= 0,...,L.
As in the image attached,the original numbering in the case k=1 is [ 1 2 3 4 5 6 7 8 9], i want the nodes to be renumbered
to a new numbering T=[2 4 5 6 8 1 3 7 9] (meaning position 2 in original comes first followed by position 4,etc.) and likewise for all k.

3. The attempt at a solution
In the first case (9 nodes), i considered the original numbering and created a matrix in that format say Q = reshape(1:m,3,[])'.
i then considered the Union of both even rows and columns (for k=1, this is 2) i.e. G = (Q(2,:)$\cup$Q(:,2)). then
subsequently find the difference with the original, i.e. H= (Q-G).I then store them in a vector as [G H].

currently it works for k= 1,2 but not any further.
Any assistance will be appreciated.

Note:
From the attached image; Blue(first), Purple(second), gold (third).

k=1; T =[2 4 5 6 8 1 3 7 9]
k= 2; T= [2 4 6 7 8 9 10 12 14 16 17 18 19 20 22 24 3 11 13 15 23 1 5 21 25].

Attached Files:

• gridNumber.png
File size:
15.7 KB
Views:
100
Last edited: Feb 21, 2013