Replace NaN with median per column
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi,
I have a matrix where I have NaN values in a few columns.
I would like to fill the NaN values with the median value of that column. How do I do that?
댓글 수: 0
답변 (4개)
Yazan
2021년 8월 10일
clc, clear
x1 = randn(5, 5);
x1(randi(numel(x1), 1, 5)) = nan;
x2 = fillmissing(x1, 'movmedian', size(x1,1)*2, 1);
display(x1)
display(x2)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 NaNs에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!