I have a vector A
in Matlab of dimension (mxn)x1
composed by real numbers greater or equal then zero, e.g. m=3,n=4
A=[1;0;0;0;0.4;0.7;0.5;0.6;0.8;0;1;6]
which looks like
A=[1
0
0
---
0
0.4
0.7
---
0.5
0.6
0.8
---
0
1
6]
We can see that A
is composed by n
subvectors of dimension m
. I have a vector B
of dimension gx1
, with g
greater or equal than m
, composed by ones and zeros such that the total number of ones is equal to m
, e.g. g=9
B=[1;0;0;0;0;0;0;1;1]
which looks like
B=[1
0
0
0
0
0
0
1
1]
I want to create a matrix C
of dimension gxn
in which the entries of each subvector of A
are placed in correspondence of the ones in g
for each column of B
, e.g.
C=[1 | 0 | 0.5 | 0
0 | 0 | 0 | 0
0 | 0 | 0 | 0
0 | 0 | 0 | 0
0 | 0 | 0 | 0
0 | 0 | 0 | 0
0 | 0 | 0 | 0
0 | 0.4| 0.6 | 1
0 | 0.7| 0.8 | 6]
Loops are fine only if very fast. Real dimensions of matrices are very large (e.g. mxn=100000, g=50000
)