필터 지우기
필터 지우기

How can I center a matrix containing NaN values?

조회 수: 2 (최근 30일)
Patrick
Patrick 2013년 10월 30일
댓글: Patrick 2013년 10월 30일
I have a matrix of size 72x144. It contains many NaN values, but also contains numeric values. I have been successful in the past at centering matrices containing only numeric values using the following code:
xctr=bsxfun(@minus, x, sum(x)/size(x, 1));
However, this seems to output a matrix with all NaN values, rather than giving me many NaN values, and also the centered numerical values. How can I center the data without turning everything into NaN?
  댓글 수: 2
Image Analyst
Image Analyst 2013년 10월 30일
What does it mean to "center" a matrix with nan's sprinkled throughout it? Can you give a small example of the input matrix and desired output matrix?
Patrick
Patrick 2013년 10월 30일
ex:
X = [ NaN NaN NaN | 6 4 2 | NaN 4 NaN ]
want:
xctr = [ NaN NaN NaN | 2 0 -2 | NaN 0 NaN ]

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

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 10월 30일
if you statistic toolbox
xctr=bsxfun(@minus, x, nansum(x)/size(x, 1));

추가 답변 (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