Challenge

Week 3 Challenge- MATLAB Module for calculating Global Stiffness Matrix

We have to claculate the indicidual siffness matrix and global siffness matrix for given problem.

First we calculate the number of nodes and number of elements by numbering elements and nodes in proper order in diagram. After finding the maximum number of degrees of freedom that can be associated with the structure, we will preassign the stiffness matrix initializing it as zero matrix. We will looped over the number of elements used to control the flow operator using concept of nested function.

Following are the programmes for axial element stiffness matrix and global stiffness matrix with explanation of codes -

1) Function to calculate Axial stiffness matrix -

 function [stiffness]=Axial_element_stiffness(dof,node_xy,E,A)

stiffness = zeros(size(node_xy,1));

node_x=node_xy(:,1);
node_y=node_xy(:,2);

x_co=node_x(2,1)-node_x(1,1);
y_co=node_y(2,1)-node_y(1,1);

length_element=sqrt(x_co*x_co+y_co*y_co);

c=x_co/length_element
s=y_co/length_element
stiffness = ((E*A)/length_element)*[c*c c*s -c*c -c*s; c*s s*s -c*s -s*s;
    -c*c -c*s c*c c*s; -c*s -s*s c*s s*s];

end

Explanation of codes -

function - to create function for given inputs.

zeros - to create zeros matrix.

node_x and node_y - to take values of column 1 and 2 resp.

x_co and y_co - to calculate difference between coordinates in the nodes to calculate.

length_element - to calculate the length element using appropriate equation.

c and s - to calculate values for further matrix values.

sitffness - to calculate the stiffness for axial stiffness matrix.

end - to end the function.

2) Function to calculate Global stiffness matrix -

 function [Stiffness_matrix]=Global_stiffness_matrix(node_xy,elements,E,A)
no_nodes=size(node_xy,1);
no_elements=size(elements,1);
dof=2*no_nodes;
Stiffness_matrix=zeros(2*no_nodes);
for e=1:no_elements
    element_nodes= elements(e,1:2);
    node_co=node_xy(element_nodes,:);
    stiffness= Axial_element_stiffness(dof,node_co,E,A);
    element_dof=2*(element_nodes(1)-1)+1:2*(element_nodes(1)-1)+2;
    element_dof=[element_dof 2*(element_nodes(2)-1)+1:2*(element_nodes(2)-1)+2];
    Stiffness_matrix(element_dof,element_dof)=...
        Stiffness_matrix(element_dof,element_dof)+stiffness;
end

Explantions of codes -

function - to create a function for calculating global stiffness matirx with given inputs as node coordinates, elements, E,A.

size - to calcualte size which will actually give us number of nodes and same for calculateing the number of elements.

zeros - to create zeros matrix with respect to number of nodes.

for - to create loop which will transverse through the number of elements.

element_nodes and node_co - to calculate teh element nodes and node coordinate resp.

stiffness - to call the function into another function.

element_dof - to calculate the degree of freedom using appopriate equation.

stiffness matrix - to perform the concatenation of individual matirces to generate global stiffness matirx.

end - to end the function.

Results :-

Mastan 2 analysis on the given structure -

● Model information -

● Moment about Z -


● Shear Y values -

● Shear Z values -

● Displacement at the point of application of loads -

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.