Error using eig Input matrix contains NaN or Inf.
17 views (last 30 days)
Show older comments
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
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.
Answers (1)
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:
- Check if any of the variables used to compute the matrix contains NaN or Inf values. Use the ‘isnan’ and ‘isinf’ functions to check if any of the variables contain NaN or Inf values.
- 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.
0 Comments
See Also
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!