fill missing values inside a dataset that contains nan

조회 수: 1 (최근 30일)
Reyasudin
Reyasudin 2013년 5월 29일
Hi all,
I have a dataset of some weather variables such as rainfall and solar radiation. But there are some missing values in the database. I am clueless on how to fill the missing values using interpolation method.
I cannot delete the entire row with Nans since it will affect the overall results.
I have tried to refer to some examples but still not working my dataset is called mersing which contains 1029 rows and 8 columns. The weather data start from column 5 up to column 8.
the dataset looks like this( station no, year, day, rainfall, windspeed, solarradiation, evaporation)
Here are sample of my code that I am currently working on which based on answer provided by Sven but still not working.
load mersing_data fulldata_mersing = mersing; for c = 5:size(mersing,2) % start loop from column 5 until all column nanRows = isnan(mersing(:,c)); nanRows = fullData_mersing(nanRows,c) == interp1(mersing(~nanRows,1), mersing(~nanRows,c), mersing(nanRows,1)); fulldata_mersing(nanRows,c) = interp1(mersing(~nanRows,1), mersing(~nanRows,c), mersing(nanRows,1), 'nearest','extrap'); end

채택된 답변

Image Analyst
Image Analyst 2013년 5월 29일
  댓글 수: 1
Reyasudin
Reyasudin 2013년 5월 29일
The John D'Errico's inpaint_nans solved my problems...tq for the info

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Weather and Atmospheric Science에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by