Using Diff() with NaN values

34 次查看(过去 30 天)
david crowley
david crowley 2021-4-2
I am trying to find the difference between rows using the diff() function. However, because the rows contain NaN values I am getting the following error.
'Check for missing argument or incorrect arugument data type in call to function diff'
The data is a timetable with weekly closing stock prices and I just need to calculate the difference in price between weeks.
  1 个评论
david crowley
david crowley 2021-4-3
编辑:david crowley 2021-4-3
I've tried to use the following to replace the NaN values, which worked - but trying to use the diff() function in a timetable does not.
fillmissing(C,"constant",0);

请先登录,再进行评论。

回答(1 个)

Sulaymon Eshkabilov
You can substitute all 'nan' values with 0's by locating them via isnan() and then substituting.

类别

Help CenterFile Exchange 中查找有关 Financial Toolbox 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by