NaN determinant in stiffness matrix

14 views (last 30 days)
Giuseppe Anaclerio
Giuseppe Anaclerio on 20 Mar 2019
Commented: David Goodmanson on 21 Mar 2019
Hi, I'm writing a finite element code for a exam project. My problem is about the global stiffness matrix K. When I try solving the matrix equation KU = F with linsolve function o writing U = K \ F, I get this error: "Warning: Matrix is singular to working precision.". So I try to calculate the determinante of K and I get a NaN value. But I think determinant should be a finite value or 0 and not NaN beacuse there are no divisions among the operations to calculate the determinante. So how is possible?
I have the same code working well in Wolfram Mathematica and determinant is a big value: 1.15e912.
Could you please give me some advices to solve this problem? Thank you.
  1 Comment
David Goodmanson
David Goodmanson on 21 Mar 2019
Hi Guiseppe,
evidently your K matrix contains a lot of large numbers. Hopefully you will be able to scale the problem and use different units for the variables to get the numbers down, e.g. for Young's modulus, 1e9 N/m^2 = 1e3N/(mm)^2.
It's easy to get NaN in this situation. Determinants consist of sums and differences of products, so:
a = 1e200;
b = 2e200;
c = 3e200;
d = 4e200;
a*b - c*d
ans = NaN

Sign in to comment.

Answers (0)

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!