MATLAB: Subtracting matrix subsets by specific rows

后端 未结 5 1767
刺人心
刺人心 2020-12-03 19:22

Here is an example of a subset of the matrix I would like to use:

1 3 5

2 3 6

1 1 1

3 5 4

5 5 5

8 8 0

5条回答
  •  广开言路
    2020-12-03 20:09

    Here's another way to implement this with bsxfun, slightly different from natan's bsxfun implementation -

    t1 = reshape(a,3,[]); %// a is the input matrix
    out = reshape(bsxfun(@minus,t1,t1(1,:)),[],3); %// Desired output
    

提交回复
热议问题