Replacing NaN with last real value

조회 수: 11 (최근 30일)
Diego Dranuta
Diego Dranuta 2020년 1월 15일
댓글: Asliddin Komilov 2020년 1월 17일
Hi folks, I have hundreds of excel files in .csv format that I have to "clean" getting rid of all teh NaN values and replacin them by the last value.
I have tryied using the repnan function but somethinf seems wrong.
Here is what i did
xlsread ECUSIMTEST0000-000-01.csv
for k=1:size(ans,2)
ans(:,k) = repnan(ans(:,k),"previous")
end
Where ans is the double imported from excel. I am a beginner in matlab so no step is trivial to me.
Thanks !!!

채택된 답변

Star Strider
Star Strider 2020년 1월 15일
If you have R2016b or later releases, use the fillmissing function.
I am not certain what you want to do, so see the method and EndValues documentation sections to fill the NaN values with the values you want. The 'previous', 'next', or 'nearest' methods would llikely be appropriate.
  댓글 수: 3
Star Strider
Star Strider 2020년 1월 15일
As always, my pleasure!
Asliddin Komilov
Asliddin Komilov 2020년 1월 17일
I have set of 25 variables (matrices), can I have repliced all zero value to NAN in all of the at once, without doing it for each of them separately?
thanks

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by