I'm not sure if I've used to correct wording in the Title to describe the problem. Please do feel free to edit it to reflect the description below.
Suppose I have a sudoku solver program and lets say the input matrix is the following,
A = randi(10,[9,9])-1;
I index the 3x3 sub-matrices columnwise from 1 to 9. Let's say the variable nSubMat representing this index can take any values between 1 to 9.
I index the submatrices in the following way,
SubMat(nSubMat) = A((1:3)+(3*floor((nSubMat-1)/3)),(1:3)+(3*mod(nSubMat-1,3)));
Now, I want to access and modify the value in the (2x3) position of SubMat without having to create SubMat in the first place(say to avoid unnecessary copies).
To elaborate, if I were to have a function submatrix() which would implement the above, my statement would look something like the following,
submatrix(A((1:3)+(3*floor((nSubMat-1)/3)),(1:3)+(3*mod(nSubMat-1,3))),[2,3]) = 5;
or even,
submatrix(A((1:3)+(3*floor((nSubMat-1)/3)),(1:3)+(3*mod(nSubMat-1,3))),[2:3,2:3]) = [1 2;3 4];
I know that Matlab interpreter automatically optimizes LHS=RHS type assignments for speed, but the above matrix operation is important for more reasons (algorithmically) than just reducing copies and speeding up the code which I will not dwell into here. I have seen the required syntax in a C++ library called Armadillo, but I'm not sure if the same can be done with MATLAB.