I have an n*n matrix and I want to extract every 3 columns and keep the result in different variables.
I know that it is possible to do it in this way:
You really shouldn't split A this way. If you really want to adress A in 3 column block then use something like
A = (1:9).*((1:9).');
%% create anonymous function which can be called as Ac(1), Ac(2) and so on
Ac = @(n) A(:,(n-1)*3+1:n*3)
octave:2> Ac(1)
ans =
1 2 3
2 4 6
3 6 9
4 8 12
5 10 15
6 12 18
7 14 21
8 16 24
9 18 27
octave:3> Ac(2)
ans =
4 5 6
8 10 12
12 15 18
16 20 24
20 25 30
24 30 36
28 35 42
32 40 48
36 45 54