# Question:Recursive assignment problem with matrices

## Question:Recursive assignment problem with matrices

Maple

Hi,

I'm having some problems with the generation of the typical stiffness matrices seen in FEA formulations. I have got an elementary matrix that is looped through the entire stiffness matrix to generate it. As there is juxtaposition between the elementary matrices, there is some recursive assignment involved that I can't handle properly. Here is the code for a 6x6 elementary matrix with a 3x3 juxtaposition. n is the nombre of recursions needed to fill the stiffness matrix. M is the elementary matrix

Here are the two codes that I have tested:

G := ZeroMatrix(3*(n-1)+6, 3*(n-1)+6);

for k to n do

G(3*(k-1)+1..3*(k-1)+6,3*(k-1)+1..3*(k-1)+6) :=G(3*(k-1)+1..3*(k-1)+6,3*(k-1)+1..3*(k-1)+6)+M:

end do

----------

G := ZeroMatrix(3*(n-1)+6, 3*(n-1)+6);

for k to n do

for i to 6 do

for j to 6 do

G(3*(k-1)+i, 3*(k-1)+j) := G(3*(k-1)+i, 3*(k-1)+j)+M(i, j):

end do

end do

end do

Can you help me? Thanks

﻿