%% HOW DO I DO THAT IN MATLAB SERIES?
% In this series, I am answering questions that students have asked
% me about MATLAB.  

%% TOPIC
% Example showing the use of matrix operations in engineering problems.
% Finite Element Analysis is a computerized method for predicting 
% how a body will react to environmental factors such as forces. Depending
% on the material of the body, the body has a stiffness, K. The behaviour
% (deformation, X) of the body under the influence of set of forces, F is
% given by the relation F=K*X.
%% SUMMARY
% Language : Matlab 2008a; 
% Authors : Sri Harsha Garapati, Daniel Miller, Autar Kaw; 
% Mfile available at
% http://numericalmethods.eng.usf.edu/blog/FEM_example5_blog.m; 
% Last Revised : January 17, 2012; 
% Abstract: This program shows you an example of using matrix operations in
% solving engineering problems
clc
clear all

%% INTRODUCTION

disp('ABSTRACT')
disp('   This program shows you an example of using matrix operations in')
disp(' solving engineering problems ')

disp(' ')
disp('AUTHOR')
disp('   Sri Harsha Garapati, Daniel Miller and')
disp('Autar K Kaw of http://autarkaw.wordpress.com')
disp(' ')
disp('MFILE SOURCE')
disp('   http://numericalmethods.eng.usf.edu/blog/FEM_example5_blog.m')
disp(' ')
disp('LAST REVISED')
disp('   January 17, 2012')
disp(' ')

%% INPUTS

% stiffness matrix [s] is in kips/inch
s=[2 0.1 0.2; 0.1 0.002 2.1; 0.2 2.1 0.03] .*10^3;

% force matrix [f] is in pounds
f=[9200; 42100; 105630];
%% DISPLAYING INPUTS

disp('INPUTS')
disp(' Stiffness Matrix,s')
% printing matrix s
disp(s)
disp('Force Matrix, F')
% printing matrix f
disp(f)
%% THE CODE

% convert the [s] matrix to lbs/in
s=s*10^3;
% using the relationship [f]=[k][x] we'll solve for [x]
% displacment matrix is [x] (inches)
x=inv(s)*f;
%% DISPLAYING OUTPUTS
disp('  ')
disp('OUTPUTS')
disp('  Output displacment matrix [x] (in)')
% printing matrix x
disp(x)
% finding the maximun displacement
max_disp=max(x);
fprintf('  The maximun displacement is %g in\n\n',max_disp)