Use of the repmat command is generally wasteful (as you pointed out in your question) and can usually be avoided. You can use Matlab's bult in binary-singleton-expansion ( bsxfun) to achieve the results you desire in a memory efficient manner. QUESTION - is there some nice third, way, slice mode? In which I could say, view matrix as slices, add vector to slices, and drop such view, and treat matrix as usual? The second one uses vectorization approach, however consumes memory a lot, in the first case, there is no vectorization approach (manual loop), but the memory is not overused. Repeat the vector and then add entire repeated vector (so now it is matrix really) to the matrix Manually loop over columns, and add the vector And in the result acquire matrix (10,10) of course. So add vector to first column, add vector to second column. I would like to work with this matrix in slices (in this case column slices) and add vector to them. Now I have the problem which lies between those two modes.įor example (this is just EXAMPLE) I have a matrix (10,10) and a vector (10,1). I am new to Octave/Matlab so so far I know, you can apply matrix operation (like *) or cell-wise operation (like.
0 Comments
Leave a Reply. |