0% found this document useful (0 votes)
88 views1 page

MATLAB for Engineering Students

This document contains MATLAB code that defines functions to calculate the stiffness matrix for a spring element and assemble element stiffness matrices into a global stiffness matrix for a system of springs. It then uses these functions to assemble the stiffness matrix K for a 4 degree-of-freedom spring system and solves for the displacements u due to a force applied to degree of freedom 2.

Uploaded by

NABIL HUSSAIN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
88 views1 page

MATLAB for Engineering Students

This document contains MATLAB code that defines functions to calculate the stiffness matrix for a spring element and assemble element stiffness matrices into a global stiffness matrix for a system of springs. It then uses these functions to assemble the stiffness matrix K for a 4 degree-of-freedom spring system and solves for the displacements u due to a force applied to degree of freedom 2.

Uploaded by

NABIL HUSSAIN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

FEM ASSIGNMENT - 1

NIHAL SINGH
01FB15EME080
7TH ‘B’

MATLAB CODE:
function y = SpringElementStiffness(k)
y=[k,-k;-k,k];
function y = SpringAssemble(K,k,i,j)
K(i,i) = K(i,i) + k(1,1);
K(i,j) = K(i,j) + k(1,2);
K(j,i) = K(j,i) + k(2,1);
K(j,j) = K(j,j) + k(2,2);
y = K;
k=SpringElementStiffness(1)
K=zeros(4,4)
K=SpringAssemble(K,k,1,2)
K=SpringAssemble(K,k,2,3)
K=SpringAssemble(K,k,2,4)
k=K(2,2)
f=[10]
u=k\f

OUTPUT:
u=
3.3333

You might also like