필터 지우기
필터 지우기

How can I center a dataset with NaN values in it?

조회 수: 2 (최근 30일)
Patrick
Patrick 2013년 11월 5일
답변: Patrick 2013년 11월 6일
I know this sounds like an easy question. Really, it is. I've even asked some form of this question before. But, I have run into a new problem today. I have a 736x1 vector, called 'ARRAY4' which I am trying to center. The vector contains NaN values. The code I am using is:
ARRAY4c=bsxfun(@minus,ARRAY4,nansum(ARRAY4)/size(ARRAY4,1));
This code works fine with many other datasets, but for some reason it does not with this one. The output, rather than being centered around the average, is all positive values and NaNs. I have checked the original data several times manually to look for any anomalous values, but to no avail. What could possibly be happening here?
  댓글 수: 2
Azzi Abdelmalek
Azzi Abdelmalek 2013년 11월 5일
You said: but for some reason it does not with this one.
Which one?
Patrick
Patrick 2013년 11월 5일
This one, as in this dataset, "ARRAY4". It has worked with my other datasets, "ARRAY1", "ARRAY2", "ARRAY3", which also contain NaN values.

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

채택된 답변

Patrick
Patrick 2013년 11월 6일
As a different approach, I used:
nanmean(ARRAY4c)
to find the mean of the positive data, and centered it around that.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Language Fundamentals에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by