Using Diff() with NaN values

34 Ansichten (letzte 30 Tage)
david crowley
david crowley am 2 Apr. 2021
Bearbeitet: david crowley am 3 Apr. 2021
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 Kommentar
david crowley
david crowley am 3 Apr. 2021
Bearbeitet: david crowley am 3 Apr. 2021
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);

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov am 2 Apr. 2021
You can substitute all 'nan' values with 0's by locating them via isnan() and then substituting.
  1 Kommentar
david crowley
david crowley am 3 Apr. 2021
This doesn't work with timeseries though?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Financial Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by