getting NaN as result
1 view (last 30 days)
Show older comments
Dear MATLAB helpers,
I'm trying to run a project for 2 month but I think the problem is bad scaling.
this is the code :
K=zeros(15);
for i=1:4
Ke=bar3e(Ex(i,:),Ey(i,:),Ez(i,:),[E Ep(i,1)]);
K=assem(Edof(i,:),K,Ke);
end
Also I attached bar3e function, assem and variables value such as E , it may help.
I will be thankful for any suggestion.
All the best
4 Comments
Fabio Freschi
on 28 Aug 2014
Unfortunately I can't do some tests myself. Anyway, I have an idea. My guess is that you are trying to solve a FEM problem or similar and you are not applying constraints (or boundary conditions) to the stiffness matrix. To check if I am right, remove one row and one column from the stiffness matrix and rhs and solve the problem. This is equivalent to set an unknown to 0. For example:
% this is the unknown we want to fix to 0
ifix = 1;
% tis is not very efficient but simple!
K(ifix,:) = []; % remove row
K(:,ifix) = []; % remove col
f(ifix) = []; % rhs
% solve. The solution might be meaningless, but the system is now
% constrained and you should not have singularities anymore
x = K\f;
If this works you can try to apply meaningful boundary conditions to your system.
Let us know!
Fabio
Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements 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!