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
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.