How can I divide each row of a matrix by a fixed row?

前端 未结 3 1308
隐瞒了意图╮
隐瞒了意图╮ 2020-11-30 10:06

Suppose I have a matrix like:

100 200 300 400 500 600
  1   2   3   4   5   6
 10  20  30  40  50  60
...

I wish to divide each row by the

3条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-30 10:23

    Use bsxfun:

    outMat = bsxfun (@rdivide, inMat, inMat(2,:));
    

    The 1st argument to bsxfun is a handle to the function you want to apply, in this case right-division.

提交回复
热议问题