Matlab cumsum reset at NaN?

前端 未结 3 953
借酒劲吻你
借酒劲吻你 2021-01-12 16:16

If I have a vector of either 1\'s or NaN\'s like this:

[1 1 1 NaN 1 1 NaN 1 1 1 1]

How can I reset the cumsum to zero at the location of th

3条回答
  •  迷失自我
    2021-01-12 16:54

    There's a nice FEX file that treats this issue in this link. The code has user-specified treatment of NaNs. It allows the user to replace NaNs with zeros, or to skip over them, or to reset on NaNs, maintaining NaNs as placeholders.

提交回复
热议问题