Debashis
2012-09-12 04:58:59 UTC
Hi, I have a problem with vectorization in Octave. I have a M x N matrix A (M rows). I have another vector v of size M, each of this contains a row index for A (between 1 to N).
For every row, I want to assign a constant value to the corresponding column element.
The equivalent code using for loop is:
for i = 1:size(A, 1)
A(i, v(i, 1)) = c;
end;
What is the best way to vectorize this?
Thx.
For every row, I want to assign a constant value to the corresponding column element.
The equivalent code using for loop is:
for i = 1:size(A, 1)
A(i, v(i, 1)) = c;
end;
What is the best way to vectorize this?
Thx.