How to select the row of an element in a vector and put it in the same row for a different matrix?
1 view (last 30 days)
For example, vector A is a 3x1 and has the value 1 in its third row. I want to then take the sum of the entire vector A and put this sum in a 3x5 matrix B (currently filled with NaN's) in the first column third row. I want to keep doing this for each subsequent column-- so for a second round, if vector A (3x1) has the value 1 in the first row, I want to put the sum of all numbers into the second column first row of matrix B.
More Answers (1)
dpb on 16 Feb 2016
Well, much is undefined but the indexing is pretty simple...
Now, you'll have to iterate or otherwise set the column index and regenerate A and it's presumed there will only be a single value of '1' in A (else't you'll get more than one value set in B or none if didn't happen to have any). Also A must be a vector of length<=size(B,1) or you'll also be changing the size of the B array.