Retrieving element index in spfun, cellfun, arrayfun, etc. in MATLAB

后端 未结 3 1648
情书的邮戳
情书的邮戳 2021-02-07 13:06

Is there any way to retrieve the index of the element on which a function called by cellfun, arrayfun or spfun acts? (i.e

3条回答
  •  南笙
    南笙 (楼主)
    2021-02-07 13:22

    It's simple. Just make a cell like: C = num2cell(1:length(S)); then: out=arrayfun(@(x,c) c*x,S,C)

提交回复
热议问题