Using Diff() with NaN values

조회 수: 33 (최근 30일)
david crowley
david crowley 2021년 4월 2일
편집: david crowley 2021년 4월 3일
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
Sulaymon Eshkabilov 2021년 4월 2일
You can substitute all 'nan' values with 0's by locating them via isnan() and then substituting.
  댓글 수: 1
david crowley
david crowley 2021년 4월 3일
This doesn't work with timeseries though?

댓글을 달려면 로그인하십시오.

카테고리

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