Row/column counter in 'apply' functions

后端 未结 5 505
遥遥无期
遥遥无期 2020-12-08 04:32

What if one wants to apply a functon i.e. to each row of a matrix, but also wants to use as an argument for this function the number of that row. As an example,

5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-08 05:27

    Actually, in the case of a matrix, you don't even need apply. Just:

    test^(1/row(test))
    

    does what you want, I think. I think the row() function is the thing you are looking for.

提交回复
热议问题