Hello,
I have taken a look in your code, I relize that in each element there are four nodes and each node has two degree of freedom. Therefore, the element matrix of each element are 8x8.
To assemble element matrix to your global matrix, you should loop for each elment and just assemble its matrix to the global matrix.
The problem is that you have to find the approriate index to assembe emement matrix of each element. To do this, you can find the index according to the node of each element. For example, in your code the first element is
NODES(1,:)
ans =
1 22 23 2
therefore, the index of this element in the global matrix will be
[2*NODES(1,:)-1 2*NODES(1,:)]
ans =
1 43 45 3 2 44 46 4
when you have found this index, you just assembe to global matrix by
BIGK(INDEX,INDEX) = BIGK(INDEX,INDEX) + EK;
Summary, you could change your code to
BIGK = zeros(NNODE*NDFPN,NNODE*NDFPN);
for I = 1:NELE
INDEX = [NODES(I,:)*2-1 NODES(I,:)*2];
BIGK(INDEX,INDEX) = BIGK(INDEX,INDEX) + EK;
end
Aslo, at the end of your code in Problem_2.m, you should change
to
since there is a different between / and \. You can refer more detail of "\" by this link
https://www.mathworks.com/help/matlab/ref/mldivide.html
3 Comments
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/472570-assembling-global-stiffness-matrix#comment_726369
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/472570-assembling-global-stiffness-matrix#comment_726369
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/472570-assembling-global-stiffness-matrix#comment_726370
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/472570-assembling-global-stiffness-matrix#comment_726370
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/472570-assembling-global-stiffness-matrix#comment_726375
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/472570-assembling-global-stiffness-matrix#comment_726375
Sign in to comment.