NaN with backslash operator

조회 수: 18 (최근 30일)
Sun
Sun 2019년 4월 29일
편집: Sun 2019년 7월 31일
Hi,
I would like to understand the reason as to why the below operation is giving a NaN solution for the attached data.
x = A\B;
Thank you.
YK..

채택된 답변

Adam Danz
Adam Danz 2019년 4월 29일
The following rows of your variable "B" contain NaN values.
find(isnan(B))
ans =
1491
1492
1493
1494
1495
1496
1497
To ignore the NaN values,
nanIdx = isnan(A) | isnan(B);
A(~nanIdx) \ B(~nanIdx)
ans =
-0.091457
  댓글 수: 2
John D'Errico
John D'Errico 2019년 4월 29일
The problem being that NaNs propagate. Everything they touch, turns to NaN. (Like old King MIdas, but in an even worse way.) So if you already have NaNs in your data, give it up. You need to excise them from your data before any linear algebra computations.
Steven Lord
Steven Lord 2019년 4월 29일
FYI the functions listed in the "Missing Data and Outliers" section of this documentation page may be of use in locating, removing, and/or replacing the NaN values in the data.

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by