Error using eig Input matrix contains NaN or Inf.

17 views (last 30 days)
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 Comments
Omer Iqbal
Omer Iqbal on 16 Feb 2023
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 on 16 Feb 2023
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.

Sign in to comment.

Answers (1)

Sarthak
Sarthak on 9 Mar 2023
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.

Categories

Find more on Resizing and Reshaping Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!