I'm quite new to programming so am looking for some experts to nudge me in the right direction as I complete this exercise.
I have used horzcat and vertcat to manually do this but I'm asking if anyone knows a simpler way.
Matrix 1 is 18x18 and indexed horizontally starting at 1.
Matrix 1 is at the centre and represents a discrete space. Matrix 2,3,4,5,6,7,8,9 are replicates of matrix 1, also represent discrete spaces and are located right, lower right, below, lower left, left, top left, above and top right.
Matrix 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 are also replicates of matrix one and surround Matrix 2 to 9. The matrices built together form a pattern as below. Each matrix is itself a discrete unit.
If you define the number of matrices you require, so let's say in this case '49' or '4 steps from matrix 1' (a person can jump from 1, 9, 25, 49 on a diagonal or 1, 8, 23,46 on a straight line), how do I build the matrices in this pattern?
43 44 45 46 47 48 49
42 21 22 23 24 25 26
41 20 7 8 9 10 27
40 19 6 1 2 11 28
39 18 5 4 3 12 29
38 17 16 15 14 13 30
37 36 35 34 33 32 31
If I demonstrate this diagrammatically, I hope I can express my problem better.
So the first ring is this:
7 8 9
6 1 2
5 4 3
the second ring is this:
21 22 23 24 25
20 7 8 9 10
19 6 1 2 11
18 5 4 3 12
17 16 15 14 13
the third ring is
43 44 45 46 47 48 49
42 21 22 23 24 25 26
41 20 7 8 9 10 27
40 19 6 1 2 11 28
39 18 5 4 3 12 29
38 17 16 15 14 13 30
37 36 35 34 33 32 31
and so on. I'd like to be able to continue this pattern infinitely.
What is the best way to do this in Matlab?
I apologise for my lack of clarity and need to express my problem better. All your comments are very useful in showing me how to write a proper problem.
Many thanks for your help guys. Just joined this forum as the support here is exceptional.