필터 지우기
필터 지우기

Polyfit function - NaN

조회 수: 8 (최근 30일)
Gina Carts
Gina Carts 2019년 3월 18일
답변: Guillaume 2019년 3월 18일
I have the age and blood measurement of some data. For some people the age is missing and I marked them as NaNs.
When I used the function polyfit to calcualte the slope and intercept it returns NaN values.
How can I deal with a missing data? Ideally I would like to keep the people with missing age.
age=[29, 31, 28, 34, 28, 31, 25, 27, 29, NaN]
measure=[82.2699,65.9515,71.3140,66.6908,76.5600,71.3734,94.6844,90.4026,95.950,97.2310]
>> polyfit(age,measure,1)
>> ans =
NaN NaN
  댓글 수: 3
Gina Carts
Gina Carts 2019년 3월 18일
The NaN was a missing information. Can I put something else instead of NaN or should I remove that person from the sample?
Torsten
Torsten 2019년 3월 18일
Does this person add information to the sample ? I guess, no. So you should remove it from the data analysis.

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

답변 (1개)

Guillaume
Guillaume 2019년 3월 18일
polyfit cannot cope with missing data.So, if you want to use polyfit you have but no choice to remove that missing data.
If the reason for the missing data is completely random, then it's not an issue. If the reason for the missing data is not random, then you'll have to employ statistic methods that are robust to missing data and you need to do some research.

카테고리

Help CenterFile Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by