Matlab: add vector to matrix

前端 未结 2 803
滥情空心
滥情空心 2021-01-02 22:06

I have a 3XN matrix representing a list of 3D coordinates,something like

33    33    33    33    34    34    34    34    34    35    35
17    18         


        
2条回答
  •  孤独总比滥情好
    2021-01-02 22:37

    Use repmat:

    M = randn(3, N);           % your 3 x N matrix
    v = randn(3, 1);           % your vector
    r = M + repmat(v, [1 N]);  % add v to every column of M
    

提交回复
热议问题