I am solving a system of arrays in matlab for a finite element analysis class. I am using a for loop to create L arrays that after looped will be changed based on the "Element" number that is being presented. The array is created properly the first time through the loop but the second time through it fails on line 7 each time with the error "Index in position 1 exceeds array bounds (must not exceed 1)." The first L array that is created is L=[1 0;0 1;0 0;0 0;0 0]; the second array should be L=[0 0;1 0;0 1;0 0;0 0]; Can anyone figure out how I am getting this error? Also I have used the exact same code before to make 4x5 matrices for L and it worked fine. Below is the function I use to construct the L with some other calculations. The second set of code is the inputs to the function.
function [KG,U] = Stiffness1(Elements,Nodes,E,A,L,BC,F)