I'm having problems getting a linear index to return the results in the form that i want.
Suppose we have three matrices:
Matrix A: 100x81
Matrix B: 9x20
I want to multiply A with B, but only the parts that are referred by the index. If we have Matrix A indexed like so:
A(:, Index), we get a 100x441 result, which is partially what i want. The 441 result is basically all of the results from A in linear index sequence (9*49). What i want is for the 49 dimension to get concatenated vertically (4900x9) instead of horizontally (100x441), like so:
What it returns (100x441)
1 2 3 ... 441
What i want it to return (4900x9)
1 2 3 ... 9
My solution so far was to use reshape to get the matrix in the form that i wish, which is concatenated across the columns instead of rows, like so:
X = reshape(A(:, Index), 100*49, 9) * B;
I then reshape X again to return it to the form i want:
X = reshape(X, 100, 49, 20);
The problem with this solution is that reshape takes some processing power, and i think that it's possible to manipulate the index in a way that returns the 4900x9 row directly, and that would be way more efficient. Is this possible?
I want to multiply indexed A with B, and have it return a 100x49x20 result in the fastest way possible.