필터 지우기
필터 지우기

Error using eig Input matrix contains NaN or Inf.

조회 수: 15 (최근 30일)
Omer Iqbal
Omer Iqbal 2023년 2월 16일
답변: Sarthak 2023년 3월 9일
Hi !
I am using surfaces ( trimesh containing triangles) in a Matlab. I am getting the error mentioned below;
Error using eig
Input matrix contains NaN or Inf.
Error in FASTGUI/RunEDButtonPushed (line 1474)
[Results(k).DTen(i).eeigVec, Results(k).DTen(i).eeigVal] = eig((Results(k).DTen(i).etensor +
Results(k).DTen(i).etensor')/2); % Expanded form because ML rounding errors was giving
non-symmetric tensor and complex numbers
Error using matlab.ui.control.internal.controller.ComponentController/executeUserCallback (line 410)
Error while evaluating Button PrivateButtonPushedFcn.
Any suggestions on how to fix NaN or inf errors?
Thanks!
  댓글 수: 3
Omer Iqbal
Omer Iqbal 2023년 2월 16일
Hey!
Thanks! I put a breakpoint at line 1474 and have noticed that several parameters have NaN values in it ( Please see attached snapshot)
I used the dbstop if nanif but it didnot work for me and gave me same errors. I am not sure where the problem is located either its in the input ( surfaces) or some parameters.
Walter Roberson
Walter Roberson 2023년 2월 16일
I cannot tell from that which of the parameters have NaN in them.
Are you interpolating to get surface coordinates? If so then which interpolation are you using? Some of the interpolations give NaN by default when the coordinates of interpolation are outside of the convex hull of the scattered points.

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

답변 (1개)

Sarthak
Sarthak 2023년 3월 9일
Hi,
To fix this error, you need to identify the matrix that contains NaN or Inf values and handle them appropriately. Refer the following methods to fix the error:
  1. Check if any of the variables used to compute the matrix contains NaN or Inf values. Use the ‘isnan and ‘isinffunctions to check if any of the variables contain NaN or Inf values.
  2. If NaN or Inf values are present in the matrix, you can replace them with appropriate values. For example, you can replace NaN values with zeros or the mean of the non-NaN values in the matrix.
In your case, it seems like the matrix ‘Results(k).DTen(i).etensor or ‘Results(k).DTen(i).etensor contains NaN or Inf values. You can use the above suggestions to identify and handle the NaN or Inf values appropriately.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by