Introduction To Matlab
Introduction To Matlab
Objectives
In this lab you will become familiar with the Matlab environment and practice the use of
variables, vectors and matrices.
The command window allows you to interact with the program by writing basic in-
structions. The workspace allows you to see which variables are currently defined.
Basic operations
The simplest use of Matlab is to perform operations in the command window. Try the
following commands and check your understanding of the hierarchy of operations. Check
the lecture notes when necesssary.
>> 8*3^2/4
>> (4 - 2)/2/4
For introducing a number multiplied by a power of 10 we can use the following short
notation
>> 1e4
>> 8.324e8
>> 2.1e-5
1/21
Dr Zia R Tahir Mechanical Engineering Department, UET Lahore
Variables
Define the following variables in the Matlab command window
>> x = 1.549
>> y = -2.001
>> z = 4.578
>> a = x + y
>> b = x*y^2 + z
Note that, if a command is finished with a semicolon, the answer is not shown in the
screen. Try the following:
>> c = x*y;
>> d = x + y + a;
The value of a variable can be checked by writing its name in the command window.
Try the following:
>> a
>> d
A variable can be deleted by using the command clear followed by the name of the
variable/s that you want to delete. Try the following command:
>> clear c d
Note that the variables c and d have disappeared from the workspace, so they are no
longer available to be used. This means, that the following command will produce an
error:
>> a + d
The command clear all deletes all the variables in the workspace.
By default, Matlab shows the result on the screen by using four decimal places. You
can change the look of the output by using the command format. Try the following
commands:
>> b
There are other possibilities. Check all of them by typing on the command window
2/21
Dr Zia R Tahir Mechanical Engineering Department, UET Lahore
Functions
Matlab has a huge number of built-in functions that can be used. Try the following
functions:
>> abs(2.4)
>> abs(-1.894)
>> abs(a)
>> abs(b)
>> sin(pi/2)
>> cos(pi/4)
>> tan(3*pi/2)
>> sind(90)
>> cosd(45)
>> tand(270)
>> sqrt(2)
• Open the Matlab help and search for the word logarithm
The Matlab help is usually much better, as it shows examples of how to use a particular
function.
Vectors
Row vectors
Row vectors can be defined by using square brackets and introducing all the components
of the vector separated by commas or spaces. Try the following commands:
3/21
Dr Zia R Tahir Mechanical Engineering Department, UET Lahore
It is also possible to define vectors using the command linspace or the syntax:
initial:step:final
Check the lecture notes and try the following examples:
>> v1 = linspace(-1,1,10)
>> v2 = linspace(3,5,5)
>> w1 = [0:0.5:2]
>> w2 = [0:6]
>> w3 = [10:-1:6]
Column vectors
Column vectors can be defined by using square brackets and introducing all the compo-
nents of the vector separated by semicolons. Try the following commands:
A column vector can also be defined by transposing a row vector. Try the following
command:
>> s1 = transpose(v1)
>> v + v2
>> w-v1
>> w3-w1
>> v*s
>> v*w
>> v*w3
>> v(2)
>> w3(4)
4/21
Dr Zia R Tahir Mechanical Engineering Department, UET Lahore
It is possible to access to several components at the same time by using the syntax
initial:step:final
Check the lecture notes and try the following commands:
>> v1(2:4)
>> s(5:-2:1)
It is common to require the maximum/minimum value of a vector and where (in which
component) is the maximum/minimum located. Try the following commands:
>> h = max(v)
Returns the maximum value of the vector v in a variable named h.
>> length(s)
Plots
Matlab allows us to represent functions by using two vectors. The first vector must contain
the list of x coordinates and the second vector their images. Try the following:
>> x = [0:5:360];
>> y = sind(x);
>> plot(x,y)
The colour of the line can be changed adding an extra argument to the plot command.
Try the following:
>> plot(x,y,’k’)
>> plot(x,y,’r--’)
>> plot(x,y,’g-s’)
A complete list of all the available options is given in the help. Try the following:
5/21
Dr Zia R Tahir Mechanical Engineering Department, UET Lahore
After writing help plot, click on the link doc plot to see more examples.
Note that every time we produce a plot, the previous one disappears. To maintain the
previous plot and produce a new plot in the same figure, we will use the command hold
on. Close the figure and try the following:
>> z = cosd(x);
>> plot(x,y,’k--’)
>> hold on
>> plot(x,z,’r-’)
When different plots are drawn in the same figure, it is necessary to introduce a legend.
Try the following:
>> legend(’sinus’,’cosinus’)
• A title
>> title(’Trigonometric functions’)
Matrices
A matrix can be defined by writing the coefficients between square brackets. A space or
a comma means a change of column and a semicolon a change of row. Try the following
instructions:
>> B = [3 4; 6 9; -1 0; 2 1]
>> C = [3 5 2; -1 0 -1]
>> D = [3 0 1; 0 12 9; 8 7 2]
Matrices can be defined by using existing vectors and/or matrices. Try the following:
>> x = [1, 5, 0]
>> y = [-1, 5, 2]
>> X = [x; y]
>> Y = [x; A; y]
Note that you will receive an error if the dimensions are not consistent. For instance:
>> Z = [x, A]
6/21
Dr Zia R Tahir Mechanical Engineering Department, UET Lahore
A matrix can also be defined by multiplying a row vector by a column vector. Try the
following:
>> x = [1, 5, 0]
>> y = [-1, 5, 2]
>> A = transpose(x)*y
There are some special matrices than can be built without writing all the components
one by one. The most useful functions are zeros, ones and eye. See the following
examples:
• >> A1 = zeros(3,4)
Builds a matrix with 3 rows and 4 columns filled in with zeros
• >> A2 = ones(6,2)
Builds a matrix with 6 rows and 2 columns filled in with zeros
• >> A3 = eye(5)
Builds an identity matrix of dimension 5. Note that this is equivalent to eye(5,5)
>> A + C
>> D - A4
>> A*C
>> A*A1
>> transpose(B)*transpose(A1)
It is possible to solve linear systems of equations by using the backslash operator. Try
the following:
>> sol = D\r This is the solution of the system of equations with matrix D and
right hand side r.
You can check that D*sol=r.
>> A(1,3)
>> B(3,2)
7/21
Dr Zia R Tahir Mechanical Engineering Department, UET Lahore
It is possible to access to several components at the same time by using the syntax
initial:step:final for both rows and columns. Check the lecture notes and try the
following commands:
>> B(1:2,1)
>> B(1:2:3,2)
>> B(2,1:2)
>> B(:,1)
>> D([1,3],1)
>> D([1,3],:)
>> D([1,3],[1,3])
It is common to require the maximum/minimum value of a matrix and where (in which
component) is the maximum/minimum located. Try the following commands:
>> max(A) Returns a vector with the maximum value of each row of A.
>> [h,p] = max(A) Returns the maximum value of each row of A in a variable
named h and the rows of A containing the maximums is given in p.
>> C = [3 5 2; -1 0 -1]
>> size(C)
Review questions
Select the answer that you would obtain in Matlab if the following instructions are intro-
duced in the command window.
Note. Some of these questions appeared on past examinations. No calculator or
computers were allowed in the exam. Therefore, answer the questions first and check
your answers later by writing the expression in the Matlab command window.
1. >> 4*5^2
a) 40 b) 400 c)100 d) None of these
2. >> 4 + 2*16/2^4
a) 65540 b) 8 c)6 d) None of these
8/21
Dr Zia R Tahir Mechanical Engineering Department, UET Lahore
4. >> (8 - 4)/2/4
a) 8 b) 4 c)0.5 d) None of these
8. >> v = linspace(-5,5,11);
>> w = v(1:3:10)
a) w = [-5, -2, 1, 4] b) w = [1, 4, 7, 10]
c) w = [1; 4; 7; 10]; d) None of these
9. >> v = [0, 2];
>> w = v*2 - 1;
>> x = transpose(v)*w
a) x = [0, 0; -2 4] b) x = [0, 0; -2 8] c)Error d) None of these
9/21
Dr Zia R Tahir Mechanical Engineering Department, UET Lahore
Objectives
In this lab we will practise the creation of Matlab scripts and functions.
For each exercise it is mandatory to create a sketch following the recommendations
given in the lecture notes before trying to perform the implementation in Matlab.
Worked example
The displacement of a uniformly loaded cantilever beam attached to a wall at x = 0
and free at x = L is given by
wL4 4
y=− X − 4X 3 + 6X 2 ,
24EI
where w is the load per unit width of the beam, L is the length of the beam, E is
the Young modulus, I is the moment of inertia and X = x/L.
• Name: cantileverUniform.m
• Inputs: x, L, w, I, E
• Output: y
• Matlab header: function y=cantileverUniform(x,L,w,I,E)
Matlab implementation
f u n c t i o n y=c a n t i l e v e r U n i f o r m ( x , L , w, I , E)
%
% Inputs :
% x : position
% L : l e n g t h o f t h e beam
% w: uniform load
% I : moment o f i n e r t i a
% E : Young modulus
%
% Output :
% y : displacement
%
10/21
Dr Zia R Tahir Mechanical Engineering Department, UET Lahore
% Non−d i m e n s i o n a l p o s i t i o n
X = x/L ;
% Displacement
y = −w∗Lˆ 4 ∗ (Xˆ4 − 4∗Xˆ3 + 6∗Xˆ 2 ) / ( 2 4 ∗E∗ I ) ;
b) Write a Matlab script that defines the load w = 4000N, the moment of inertia
I = 863.65 × 10−8 m4 and the length of the beam L = 2.25m. Then, it computes the
displacement at the mid point of the beam for the three materials listed in Table 1
and writes three messages on the screen with the results.
Material E
Steel 2.0 × 1011 Pa
Aluminium 6.9 × 1010 Pa
Oak 1.1 × 1010 Pa
Sketch
• Name: mainCantilever.m
• Data: L, w, I, Esteel, Ealum, Eoak
• Output: Messages on the screen
Matlab implementation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% m a i n C a n t i l e v e r .m
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% C l e a r memory and t h e s c r e e n
clear all ; clc ;
% Data −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
E s t e e l = 2 . 0 e11 ; % Young modulues S t e e l [ Pa ]
Ealum = 6 . 9 e10 ; % Young modulues Aluminium [ Pa ]
Eoak = 1 . 1 e10 ; % Young modulues Oak [ Pa ]
I = 8 6 3 . 6 5 e −8; % Moment o f i n e r t i a [mˆ 4 ]
L = 2.25; % Length o f t h e beam [m]
w = 4000; % Uniform l o a d [N]
% Computations −−−−−−−−−−−−−−−−−−−−−−−−−−−−
% Mid p o i n t
x = L/2;
% D i s p l a c e m e n t f o r each m a t e r i a l
y S t e e l = c a n t i l e v e r U n i f o r m ( x , L , w, I , E s t e e l ) ;
yAlum = c a n t i l e v e r U n i f o r m ( x , L , w, I , Ealum ) ;
yOak = c a n t i l e v e r U n i f o r m ( x , L , w, I , Eoak ) ;
% Output on t h e s c r e e n −−−−−−−−−−−−−−−−−−−−
d i s p ( ’ The d i s p l a c e m e n t a t t h e mid p o i n t i s : ’ ) ;
f p r i n t f ( ’ %6.4 f m f o r s t e e l \n ’ , −y S t e e l ) ;
f p r i n t f ( ’ %6.4 f m f o r aluminium \n ’ , −yAlum ) ;
f p r i n t f ( ’ %6.4 f m f o r oak \n ’ , −yOak ) ;
11/21
Dr Zia R Tahir Mechanical Engineering Department, UET Lahore
Exercises
1. For a rectangular channel, the Manning’s formula states that
5/3
1 Au 1/2
Q= 2/3
S0 ,
n Pu
where Q is the discharge, Au is the cross sectional area of the channel and Pu is the
wetted perimeter, that are expressed in terms of the breath B and the normal depth
yu according to
Au = Byu , Pu = B + 2yu
a) Write a Matlab function that, given the breath, the normal depth, the channel
slope and the constant n, outputs the discharge.
b) Write a Matlab script that defines the breath B = 50m, the channel slope
S0 = 0.002 and the constant n = 0.04. Then, it computes the discharge for two
values of the normal depth, namely yu = 5m and yu = 10m, and writes two
messages on the screen with the results.
2. Wind tunnel experiments for a particular aerofoil have resulted in the following
formulas for the lift and drag coefficients respectively
a) Write a Matlab function that, given the angle, outputs the lift coefficient.
b) Write a Matlab function that, given the angle, outputs the drag coefficient.
c) Write a Matlab script that defines the angle, α = 2.21 degrees. Then, it
computes the lift and the drag coefficients and writes two messages on the
screen with the results.
LLW
T = b c
D L2b − D2
where D is the distance of the cable attachment point to the beam pivot.
a) Write a Matlab function that, given the distance D, the cable length Lc , the
beam length Lb and the weight W , outputs the tension T .
b) Write a Matlab script that defines the cable length Lc = 5m and the beam
length Lb = 3m. Then, it computes the tension at a point with D = Lb /4
for two different loads, namely W = 400N and W = 600N. The program must
write two messages on the screen with the results.
12/21
Dr Zia R Tahir Mechanical Engineering Department, UET Lahore
a) Write a Matlab function that, given the width b and the height h of a rectangular
section and the diameter d of a circular section, outputs both the moment of
inertia of a beam with rectangular section IR and with circular section IC .
b) Write a Matlab script that defines the width b = 10mm, the height h = 20mm
and the diameter d = 15mm. Then, it computes the moment of inertia of a
beam with rectangular section IR and with circular section IC . The program
must write two messages on the screen with the results.
13/21
Dr Zia R Tahir Mechanical Engineering Department,UET Lahore
Objectives
In this lab we will practise the control flow (conditionals) and loops.
For each exercise it is mandatory to create a sketch following the recommendations
given in the lecture notes before trying to perform the implementation in Matlab.
• Name: cantileverPunctual.m
• Inputs: x, w, I, E, a
• Output: y
• Matlab header: function y=cantileverPunctual(x,L,w,I,E,a)
Matlab implementation
f u n c t i o n y=c a n t i l e v e r P u n c t u a l ( x , w, I , E , a )
%
% Inputs :
% x : position
% w: uniform load
% I : moment o f i n e r t i a
% E : Young modulus
% a : P o i n t where t h e l o a d i s a p p l i e d
14/21
Dr Zia R Tahir Mechanical Engineering Department, UET Lahore
%
% Output :
% y : displacement
%
i f x<=a
y = −w∗x ˆ 2 ∗ ( 3 ∗ a−x ) / ( 6 ∗E∗ I ) ;
else
y = −w∗ a ˆ 2 ∗ ( 3 ∗ x−a ) / ( 6 ∗E∗ I ) ;
end
b) Write a Matlab script that defines the load w = 4000N, the moment of inertia
I = 863.65 × 10−8 m4 , the length of the beam L = 2.25m and the Young modulus
E = 2.0 × 1011 Pa. Then, it computes the displacement at the mid point of the
beam for two different positions of the applied load, namely a = L/3 and a = 2L/3.
The program compares the two values and prints on the screen a message with the
maximum of both.
Sketch
• Name: mainCantileverPunctual.m
• Data: L, w, I, E
• Computation:
– Compute x and two different values of a, say a1 and a2, as a function of L.
– Calls function mainCantileverPunctual.m twice
– Compares the two displacements
• Output: Messages on the screen (the message is decided using a conditional)
Matlab implementation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% m a i n C a n t i l e v e r P u n c t u a l .m
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% C l e a r memory and t h e s c r e e n
clear all ; clc ;
% Data −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
E = 2 . 0 e11 ; % Young modulues S t e e l [ Pa ]
I = 8 6 3 . 6 5 e −8; % Moment o f i n e r t i a [mˆ 4 ]
L = 2.25; % Length o f t h e beam [m]
w = 4000; % Uniform l o a d [N]
% Computations −−−−−−−−−−−−−−−−−−−−−−−−−−−−
% Mid p o i n t
x = L/2;
% Two d i f f e r e n t p o s i t i o n s o f t h e a p p l i e d l o a d
a1 = L / 3 ;
a2 = 2∗ a1 ;
% D i s p l a c e m e n t f o r each p o s i t i o n o f t h e a p p l i e d l o a d
y1 = c a n t i l e v e r P u n c t u a l ( x , w, I , E , a1 ) ;
y2 = c a n t i l e v e r P u n c t u a l ( x , w, I , E , a2 ) ;
% Output on t h e s c r e e n −−−−−−−−−−−−−−−−−−−−
i f y1>y2
f p r i n t f ( ’Maximum y f o r a=%6.4 f m. I t i s %6.4 f m. \ n ’ , a1 , −y1 ) ;
e l s e i f y1<y2
15/21
Dr Zia R Tahir Mechanical Engineering Department, UET Lahore
a) Create a Matlab script that defines the load w = 4000N, the moment of inertia
I = 863.65 × 10−8 m4 , the length of the beam L = 2.25m and the Young modulus
E = 2.0 × 1011 Pa. Then, it plots the shape of the undeformed and two deformed
configurations, with a = L/3 and a = 2L/3.
Sketch
• Name: plotCantileverPunctual.m
• Data: L, w, I, E
• User parameter: N, number of points for the plot
• Computation:
– Define a vector x with N points between 0 and L.
– Define three vectors filled in with zeros: y0, y1 and y2. The vector y0
will represent the undeformed configuration, y1 the deformed configuration
with a = L/3 and y2 the deformed configuration with a = 2L/3.
– Creates a loop to fill in y1 and y2 by calling the function cantileverPunctual.m
that was created in the previous Worked Example.
• Output: Plot the three configurations. Remember to:
– Use different colours for each configuration.
– Add labels to the x and y axis.
– Add a title.
– Add a legend.
Matlab implementation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% p l o t C a n t i l e v e r P u n c t u a l .m
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% C l e a r memory and t h e s c r e e n
clear all ; clc ;
% Data −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
E = 2 . 0 e11 ; % Young modulues S t e e l [ Pa ]
I = 8 6 3 . 6 5 e −8; % Moment o f i n e r t i a [mˆ 4 ]
L = 2.25; % Length o f t h e beam [m]
w = 4000; % Uniform l o a d [N]
% User parameter
N = 1 0 0 ; % number o f p o i n t s f o r t h e p l o t
16/21
Dr Zia R Tahir Mechanical Engineering Department, UET Lahore
% Computations −−−−−−−−−−−−−−−−−−−−−−−−−−−−
% Two d i f f e r e n t p o s i t i o n s o f t h e a p p l i e d l o a d
a1 = L / 3 ;
a2 = 2∗ a1 ;
% Define vector of p o s i t i o n s
x = l i n s p a c e ( 0 , L ,N ) ;
% Compute d i s p l a c e m e n t s u s i n g a l o o p
f o r i =1:N
y1 ( i ) = c a n t i l e v e r P u n c t u a l ( x ( i ) ,w, I , E , a1 ) ;
y2 ( i ) = c a n t i l e v e r P u n c t u a l ( x ( i ) ,w, I , E , a2 ) ;
end
% R e p r e s e n t t h e t h r e e c o n f i g u r a t i o n s −−−−−−−−
% Undeformed
p l o t ( x , y0 , ’ k ’ , ’ LineWidth ’ , 2 )
h o l d on
p l o t ( x , y1 , ’ b ’ , ’ LineWidth ’ , 2 )
p l o t ( x , y2 , ’ r ’ , ’ LineWidth ’ , 2 )
% Add a l e g e n d
l e g e n d ( ’ Undeformed ’ , ’ Deformed a=L/3 ’ , ’ Deformed a=2L/3 ’ )
x l a b e l ( ’ P o s i t i o n [m] ’ )
y l a b e l ( ’ D e f l e c t i o n [m] ’ )
t i t l e ( ’ C a n t i l e v e r beam p u n c t u a l l o a d ’ )
Write a Matlab function that, given the value of x and a tolerance tol, returns the
number of terms k such that the absolute value of the k-th term of the series is less
or equal than tol and the value of S(x, k).
Sketch
• Name: taylorTerm.m
• Inputs: x, tol
• Outputs: S, k
• Matlab header: function [S,k]=taylorTerm(x,tolerance)
Matlab implementation
f u n c t i o n [ S , k ] = taylorTerm ( x , t o l )
%
% Inputs :
% x : point
% tol : tolerance
%
% Output :
17/21
Dr Zia R Tahir Mechanical Engineering Department, UET Lahore
% S:
% k : i n d e x o f t h e s e r i e s term l e s s than t o l
%
% I n i t i a l i z e t h e sum
S = 0;
18/21
Dr Zia R Tahir Mechanical Engineering Department, UET Lahore
Exercises
1. For a rectangular channel, the Manning’s formula states that
5/3
1 Au 1/2
Q= S ,
n Pu2/3 0
where Q is the discharge, Au is the cross sectional area of the channel and Pu is the
wetted perimeter, that are expressed in terms of the breath B and the normal depth
yu according to
Au = Byu , Pu = B + 2yu
a) Write a Matlab function that, given the breath, the normal depth, the channel
slope and the constant n, outputs the discharge.
b) Write a Matlab script that defines the breath B = 50m, the channel slope
S0 = 0.002 and the constant n = 0.04. Then, it plots the discharge for the
normal depth varying from yu = 0m to yu = 10m.
b) Create a Matlab script that defines the load w = 4000N, the moment of inertia
I = 863.65 × 10−8 m4 , the length of the beam L = 2.25m and the Young modulus
E = 2.0 × 1011 Pa. Then, it plots the shape of the undeformed beam and two
deformed configurations, with a = L/3 and a = 2L/3.
3. For controlling the properties of some materials, it is useful to know the temperature
distribution of a rectangular metal plate of dimensions W × L. The temperature
depends on the function
2 2 nπx sinh(nπy/L)
w(x, y) = sin
π n L sinh(nπW/L)
n=1,3,5,...
a) Write a Matlab function that, given an integer number k and the point of the
plate where the temperature is required (x, y), return the value of w(x, y) where
the sum goes up to n ≤ k.
b) Write a Matlab script that defines a point x = 1 and y = 1 and plots the
temperature at this point as a function of the number of terms in the summation
k ∈ [0, 20]. What do you notice as k increases?
19/21
Dr Zia R Tahir Mechanical Engineering Department, UET Lahore
4. The static deflection of a square plate clamped on all four sides and subjected to
uniform load can be expressed in terms of the following constants Em that are
obtained from the truncation of the following infinite set of equations
a i Ei + bim Em = ci , i = 1, 3, 5, . . .
m=1,3,5,...
where
1 αi
ai = tanh αi +
i cosh2 αi
2 −1
i2
bim = 8i πm3 1+ 2
m
4 αi
ci = 3 4 − tanh αi
π i cosh2 αi
and αi = iπ/2.
Taking the first four equations, that is i = 1, 3, 5, 7, and truncating the infinite series
also to the fourth term, that is m = 1, 3, 5, 7, we obtain the following system of
equations in matrix form
⎛ ⎞⎛ ⎞ ⎛ ⎞
a1 + b11 b13 b15 b17 E1 c1
⎜ b31 a + b b b ⎟ ⎜ ⎟ ⎜ ⎟
⎜ 3 33 35 37 ⎟ ⎜ 3 ⎟ = ⎜c 3 ⎟
E
(2)
⎝ b51 b53 a5 + b55 b57 ⎠ ⎝ E5 ⎠ ⎝ c5 ⎠
b71 b73 b75 a7 + b77 E7 c7
d) Write a Matlab script that, using the functions defined in a) and b), builds and
solves the lienar system of equations given in Equation (2). The program must
output the solution of the linear system on the screen.
5. Consider two cylinders of two different materials where one cylinder just fits inside
the other. The inner radius of the inner cylinder is a, and its outer radius is b. The
inner radius of the outer cylinder is also b, and its outer radius is c. The Young’s
modulus and the Possion ratio of the inner cylinder are E1 and ν1 , respectively, and
those of the outer cylinder are E2 and ν2 , respectively. The radial stress σrr hoop
stress σθθ and radial displacement ur are given by
Ai
σrr,i (r) = + Bi
r2
Ai
σθθ,i (r) = − + Bi (3)
r2
1 + νi 1 − νi
ur,i (r) = − Ai + rBi
rEi Ei
where i = 1 refers to the inner cylinder and i = 2 to the outer cylinder.
20/21
Dr Zia R Tahir Mechanical Engineering Department, UET Lahore
If the outer surface of the outer cylinder is subjected to a compressive radial dis-
placement U0 and the inner surface of the inner cylinder has no radial stress, then
the following conditions are used to determine Ai and Bi for i = 1, 2.
Introducing these conditions into the Equations (3), the following system of equations
in matrix form is obtained:
⎛ ⎞⎛ ⎞ ⎛ ⎞
1 + a2 0 0 0 A1 0
⎜ 1 b2 −1 −b2 ⎟ ⎜B 1 ⎟ ⎜ 0 ⎟
⎜ ⎟⎜ ⎟ ⎜ ⎟
⎝−(1 + ν1 ) (1 − ν1 )b2 (1 + ν2 )E1 /E2 −(1 − ν2 )b2 E1 /E2 ⎠ ⎝A2 ⎠ = ⎝ 0 ⎠
0 0 −(1 − ν2 ) (1 − ν2 )c2 B2 −U0 E2 c
21/21