[Matlab] Grid renumbering for Matrix

  • Thread starter qwuasi
  • Start date
  • #1
8
0

Homework Statement



I have a matrix A [itex]\in[/itex] R[itex]^{m x m}[/itex] where m = n[itex]^{2}[/itex] and n = 2[itex]^{k}[/itex] +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.

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,:)[itex]\cup[/itex]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].
 

Attachments

  • gridNumber.png
    gridNumber.png
    15.7 KB · Views: 491
Last edited:

Answers and Replies

Related Threads on [Matlab] Grid renumbering for Matrix

  • Last Post
Replies
8
Views
4K
  • Last Post
Replies
2
Views
1K
  • Last Post
Replies
1
Views
2K
  • Last Post
Replies
10
Views
1K
  • Last Post
Replies
3
Views
2K
  • Last Post
Replies
3
Views
28K
  • Last Post
Replies
2
Views
1K
Replies
1
Views
611
Replies
1
Views
3K
Top