フィルターのクリア

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));
  1 件のコメント
Patrick
Patrick 2013 年 10 月 30 日
Perfect! Thank you.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by