matlab precision determint problem

Posted by ldigas on Stack Overflow See other posts from Stack Overflow or by ldigas
Published on 2010-05-07T13:06:20Z Indexed on 2010/05/07 13:08 UTC
Read the original article Hit count: 429

Filed under:
|
|

I have the following program

format compact; format short g; clear; clc;  
L = 140; J = 77; Jm = 10540; G = 0.8*10^8; d = L/3;  
for i=1:500000  
omegan=1.+0.0001*i;

a(1,1) = ((omegan^2)*(Jm/(G*J))*d^2)-2;
a(1,2) = 2;
a(1,3) = 0;
a(1,4) = 0;

a(2,1) = 1;
a(2,2) = ((omegan^2)*(Jm/(G*J))*d^2)-2;
a(2,3) = 1;
a(2,4) = 0;

a(3,1) = 0;
a(3,2) = 1;
a(3,3) = ((omegan^2)*(Jm/(G*J))*d^2)-2;
a(3,4) = 1;

a(4,1) = 0;
a(4,2) = 0;
a(4,3) = 2;
a(4,4) = ((omegan^2)*(Jm/(G*J))*d^2)-2;

if(abs(det(a))<1E-10) sprintf('omegan= %8.3f det= %8.3f',omegan,det(a))
end          
end

Analytical solution of the above system, and the same program written in fortran gives out values of omegan equal to 16.3818 and 32.7636 (fortran values; analytical differ a little, but they're there somewhere).

So, now I'm wondering ... where am I going wrong with this ? Why is matlab not giving the expected results ?

(this is probably something terribly simple, but it's giving me headaches)

© Stack Overflow or respective owner

Related posts about matlab

Related posts about fortran