# What does this mean: K12_global(1:3:6,1:3:6)?

1 view (last 30 days)
Telex on 4 Dec 2023
Edited: Image Analyst on 4 Dec 2023
K12 = K12_global(1:3:6,1:3:6)
I don't know how to interpret that indexing in matrices.
Dyuman Joshi on 4 Dec 2023
Edited: Dyuman Joshi on 4 Dec 2023
What exactly do you not know how to interpret?
Did you try searching on this forum for similar questions as mentioned in the 1st point of the help section?
Try dissecting the code into parts and see what each part does.

Torsten on 4 Dec 2023
Do you see what happens ?
The new matrix K12 is formed of the elements (1,1),(1+3,1),(1,1+3) and (1+3,1+3) of the original matrix K12_global.
K12_global = rand(9)
K12_global = 9×9
0.0194 0.0262 0.2509 0.2650 0.1267 0.3926 0.6566 0.5265 0.6897 0.7206 0.6288 0.2764 0.5182 0.3594 0.8476 0.4010 0.3064 0.1114 0.2628 0.2054 0.4492 0.5123 0.5923 0.5039 0.5320 0.6925 0.4534 0.4825 0.9864 0.0153 0.6897 0.4487 0.9993 0.0325 0.1075 0.2257 0.5787 0.9988 0.9926 0.4080 0.5705 0.6924 0.1036 0.6637 0.5976 0.0143 0.0776 0.9375 0.1070 0.0775 0.7704 0.9926 0.9436 0.0468 0.6609 0.6836 0.3231 0.5390 0.2477 0.8082 0.4072 0.4094 0.8814 0.7498 0.5859 0.3176 0.0981 0.0715 0.2600 0.2737 0.4692 0.8073 0.4474 0.8309 0.9656 0.1444 0.9107 0.9487 0.6329 0.2216 0.2917
K12 = K12_global(1:3:6,1:3:6)
K12 = 2×2
0.0194 0.2650 0.4825 0.6897

Image Analyst on 4 Dec 2023
Another example
indexes = 1 : 3 : 6
indexes = 1×2
1 4
The next index would be 7 since 4 + 3 = 7, but since it was told to stop at 6, the 7 does not get included.
K12_global = reshape(1:49, 7, 7)
K12_global = 7×7
1 8 15 22 29 36 43 2 9 16 23 30 37 44 3 10 17 24 31 38 45 4 11 18 25 32 39 46 5 12 19 26 33 40 47 6 13 20 27 34 41 48 7 14 21 28 35 42 49
K12 = K12_global(1:3:6,1:3:6)
K12 = 2×2
1 22 4 25
Basically you can see it gets the intersection of the row indexes (1 & 4) with the column indexes (1 & 4).

### Categories

Find more on Define Shallow Neural Network Architectures in Help Center and File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!