getting NaN as result

1 view (last 30 days)
Hessam
Hessam on 28 Aug 2014
Edited: per isakson on 29 Aug 2014
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
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
Hessam
Hessam on 29 Aug 2014
Thank you Fabio, I like your idea.
I did what you said but it leads to this error :
Index exceeds matrix dimensions.
Error in extract
ed(i,1:(n-1))=a(t(i,:))';
Error in FEM2
Ed=extract(Edof,a);
What should I do now??
I'm so confused, I couldn't solve this warning for a long time.
Thanks.

Sign in to comment.

Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!