0% found this document useful (0 votes)
79 views

MATLAB 4 Numerical Computations

interp1(x,y,xi) >> interp1(x,y,[5 9]) ans = 0.0276 0.0126 interp1 performs linear interpolation of y at points xi.

Uploaded by

VASUDEVA NAIDU
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views

MATLAB 4 Numerical Computations

interp1(x,y,xi) >> interp1(x,y,[5 9]) ans = 0.0276 0.0126 interp1 performs linear interpolation of y at points xi.

Uploaded by

VASUDEVA NAIDU
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 53

Numerical Computations

using
MATLAB
Contents

Computations using MATLAB

Numerical Computations Symbolic Computations

Matrices and Linear Algebra Simplifications and Substitutions


Data Analysis and Statistics Calculus
Differentiation
Polynomials and Interpolation Integration (Indefinite, Definite)
Optimization Limits
Integration and Differentiation Solution of equations
Algebric equations
Differential Equations
Differential equations
Series
Symbolic summation
Taylor Series
Matrices and Linear Algebra

Matrix Manipulation functions


zeros: Create an array of all zeros
ones: Create an array of all ones
eye: Identity Matrix
rand: Uniformly distributed random numbers
diag: Diagonal matrices and diagonal of a matrix
size: Return array dimensions
fliplr: Flip matrices left-right
flipud: Flip matrices up and down
repmat: Replicate and tile a matrix
Matrices and Linear Algebra

Matrix Manipulation functions


transpose (’): Transpose matrix
rot90: rotate matrix 90
tril: Lower triangular part of a matrix
triu: Upper triangular part of a matrix
cross: Vector cross product
dot: Vector dot product
det: Matrix determinant
inv: Matrix inverse
eig: Evaluate eigenvalues and eigenvectors
rank: Rank of matrix
Matrices and Linear Algebra
Sets of linear equations
1. Rearrange the equations
2. Write the equations in matrix form
3. Solve the matrix equations in MATLAB
MATLAB can find the solution of A.x=b in two ways:
x = inv(A)*y
x = A\y (Uses LU factorization approach)

The second method is preferred over the first as:


1. It requires lesser number of floating point operations and
hence is significantly faster.
2. The solution is generally more accurate, especially for larger
problems
Matrices and Linear Algebra
Consider the following set of equations:
x1 = 3 – 2x2 – 3x3
5x2 + 6x3 = 6 – 4x1
7x1 + 8x2 = 9
x1 + 2x2 + 3x3 = 3
Step 1: Rearrange the equations 4x1 + 5x2 + 6x3 = 6
7x1 + 8x2 + 0x3 = 9

1 2 3 x1 3
Step 2: Write the equations in 4 5 6 x2 6
matrix form
7 8 0 x3 9
Matrices and Linear Algebra
Step 3: Solve the matrix equations in MATLAB

>> A = [1 2 3; 4 5 6; 7 8 0];
>> b = [3; 6; 9];
Method 1
>> x = inv(A)*b
x=
-1.0000
2.0000
-0.0000
Method 2
>> x = A\b
x=
-1.0000
2.0000
0.0000
Data Analysis and Statistics
Let us consider the marks obtained by 10
students in 3 exams

Roll no. Subject A Subject B Subject C


1 60 85 76
2 90 75 80
3 50 55 65
4 60 77 90
5 88 76 92
6 96 88 70
7 70 77 86
8 90 79 88
9 98 78 79
10 77 89 66
Data Analysis and Statistics
Let us store the marks in a Visualize the data
matrix ‘marks’
>> plot( marks(:,1), marks(:,2:4) )
>> legend( 'A', 'B', 'C‘ )
>> marks
>> axis( [1 10 0 100] )
marks = >> xlabel ('Roll number')
1 60 85 76 >> ylabel ('Marks')
2 90 75 80
3 50 55 65
4 60 77 90
5 88 76 92
6 96 88 70
7 70 77 86
8 90 79 88
9 98 78 79
10 77 89 66
Data Analysis and Statistics
Find the average marks

Average marks for a particular Average marks of different


subject subjects for a particular student

>> av_student =
>> av_subject =
mean(marks(:,2:4),2)
mean(marks(:,2:4),1)
av_student =
av_subject =
73.6667
77.9000 77.9000 79.2000
81.6667
56.6667
or
75.6667
85.3333
>> av_subject =
84.6667
mean(marks(:,2:4))
77.6667
av_subject = 85.6667
77.9000 77.9000 79.2000 85.0000
77.3333
Data Analysis and Statistics
Find the deviation from the average
>> dev_marks = marks(:,2:4) - repmat(av_subject,10,1)
dev_marks =
-17.9000 7.1000 -3.2000
12.1000 -2.9000 0.8000
-27.9000 -22.9000 -14.2000
-17.9000 -0.9000 10.8000
10.1000 -1.9000 12.8000
18.1000 10.1000 -9.2000
-7.9000 -0.9000 6.8000
12.1000 1.1000 8.8000
20.1000 0.1000 -0.2000
-0.9000 11.1000 -13.2000
repmat(A,m,n) creates a matrix consisting of an m-by-n tiling
of copies of A.
Data Analysis and Statistics
Find the maximum marks
>> max(marks(:,2:4)) highest in subject A = 98, in
ans = subject B = 89, in subject C = 92
98 89 92

Who got the maximum marks?


>> [max_marks, max_student] = max(marks(:,2:4))
max_marks =
98 89 92 9th student got highest in subject
max_student = A, 10th in subject B and 5th in
subject C
9 10 5
Data Analysis and Statistics

Find the minimum marks

>> [min_marks, min_student] = min(marks(:,2:4))

min_marks =
minimum in subject A = 50, in
50 55 65
subject B = 55, in subject C = 65
min_student =

3 3 3
Third student got minimum in all
the subjects
Data Analysis and Statistics

Find the standard Deviation of marks


>> std_marks = std(marks(:,2:4))
std_marks =
17.0258 9.5155 9.8635

Find the median


>> median_marks = median(marks(:,2:4))
median_marks =
82.5000 77.5000 79.5000
Data Analysis and Statistics
Find the covariance matrix
>> cov_marks = cov(marks(:,2:4))
cov_marks = The diagonal gives the
289.8778 74.3222 32.5778 covariance and its square-
74.3222 90.5444 3.3556 root gives the standard
deviation
32.5778 3.3556 97.2889

>> cov_marks = diag(cov(marks(:,2:4)))’


cov_marks =
289.8778 90.5444 97.2889 Covariance

>> cov_marks = sqrt(diag(cov(marks(:,2:4))))’


cov_marks =
17.0258 9.5155 9.8635 Standard deviation
Data Analysis and Statistics
Sort the students in ascending order of total marks
>> tot_marks = sum(marks(:,2:4),2); % determine total marks
>> [sorted,rank_in_class] = sort(tot_marks)
>> disp ( [sorted rank_in_class] )
170 3
221 1
227 4
232 10
233 7
245 2
254 6
255 9
256 5
257 8
Data Analysis and Statistics
sort (A,1) Sort A column-wise
sort (A,2) Sorts A row-wise

Let A = [ 60 85 76
90 75 80
50 55 65
60 77 90 ]

>> sort (A,1) >> sort (A,2)

ans = ans =

50 55 65 60 76 85
60 75 76 75 80 90
60 77 80 50 55 65
90 85 90 60 77 90
Data Analysis and Statistics
Random number generation
rand(n) generates a nxn matrix of random numbers
rand(m,n) generates mxn matrix of random numbers

>> rand(3)
ans =
0.9105 0.4946 0.4436
0.1164 0.0736 0.3281
0.5779 0.9285 0.8889

>> rand(2,3)
ans =
0.4931 0.6566 0.4231
0.9509 0.9477 0.6800
Data Analysis and Statistics
Random number generation
For numerical experiments involving random numbers it
becomes sometimes essential to set the state of the random
generator to make the experiments repeatable.

rand (‘state’,0) resets the generator to its initial state.


rand ('state',J), for integer J, resets the generator to its J-th state.

>> rand('state',10) % sets the state of the generator


>> rand(2)
ans =
0.4493 0.9641
0.2088 0.0765
Data Analysis and Statistics
Random number generation
If you go on generating random numbers, you will get different
numbers on different runs.

>> rand('state',10) >> % Resetting the state


>> rand(2) >> rand('state',10)
ans = >> rand(2)
0.4493 0.9641 ans =
0.2088 0.0765 0.4493 0.9641
0.2088 0.0765
>> rand(2)
Different
ans =
0.0159 0.2609
0.0015 0.3469 Same random numbers obtained
after resetting the state
Data Analysis and Statistics
Normally distributed random numbers

RANDN(N) is an N-by-N matrix with random entries,


chosen from a normal distribution with mean zero, variance
one and standard deviation one.

RANDN(M,N) and RANDN([M,N]) are M-by-N matrices


with random entries.

RANDN('state',0) resets the generator to its initial state.

RANDN('state',J), for integer J, resets the generator to its J-


th state.
Polynomials and Interpolation
One-Dimensional Interpolation

>> x = [2 4 6 8 10];
>> y = [0.3679 0.1353 0.0498 0.0183 0.0067];

Let us interpolate the data


at the points xi = [5 9]
Interpolated data
>> xi = [5 9];
>> yi = interp1(x,y,xi)
yi =
0.0926 0.0125
Polynomials and Interpolation
Two-Dimensional Interpolation
>> x = [0.1875 0.3125 0.4375 0.5625 0.6875 0.8125 0.9375];
>> y = x;
>> z = [ -0.3413 -0.1963 -0.1168 -0.0001 …
0.1166 0.1962 0.3412
-0.5054 -0.2461 -0.1134 -0.0001 …
0.1132 0.2460 0.5054
-0.6097 -0.3289 -0.1728 -0.0000 …
0.1726 0.3288 0.6097
-0.7064 -0.4848 -0.3172 0.0001 …
0.3171 0.4847 0.7063
-0.8214 -0.6814 -0.4769 0.0001 …
0.4768 0.6813 0.8214
-0.8232 -0.8586 -0.5793 0.0001 …
0.5792 0.8586 0.8231
-0.5716 -0.6712 -0.4912 0.0000 …
0.4912 0.6712 0.5716 ];
>> surf(x,y,z)
Polynomials and Interpolation
Two-Dimensional Interpolation

The following code attempts to


interpolate the data at point Interpolated data
(0.5,0.5)
>> zi = interp2(x,y,z,0.5,0.5)
zi =
-0.1225
>> mesh(x,y,z)
>> hold on
>> plot3(0.5,0.5,zi,’p’)
Polynomials and Interpolation
Three-Dimensional Interpolation

vi = interp3(x,y,z,v,xi,yi,zi) interpolates to find vi, the values of


the underlying 3-D function v at the points in arrays xi, yi and
zi.

The usage is similar to interp1, and interp2


Polynomials and Interpolation
Note:
All the interpolation methods require that X (1D); X, Y (2D); X, Y and Z
(3D) be monotonic.
X,Y, and Z can be non-uniformly spaced.
Out of range values are returned as NaN.
The default in all the interpolation schemes is linear interpolation. Any
other interpolation scheme if required, may be specified at the time of
interpolation as interp1(…, ‘method’), interp2(…,’method’) etc.
The available methods are:
'nearest' - nearest neighbor interpolation
'linear' - bilinear interpolation
'cubic' - bicubic interpolation
'spline' - spline interpolation
'pchip' - piecewise cubic Hermite interpolation (PCHIP) (only with interp1)
'v5cubic' - the cubic interpolation from MATLAB 5 (only with interp1)
Polynomials and Interpolation
Data Gridding and Surface Fitting
The following code interpolates scattered, non-uniformly
spaced data and fits a surface through them
>> rand('state',0) % resets the state
>> x = rand(100,1)*4-2; % non-uniformly spaced data
>> y = rand(100,1)*4-2; % non-uniformly spaced data
>> z = x.*exp(-x.^2-y.^2);
>> xx = linspace(min(x),max(x),50);
>> yy = linspace(min(y),max(y),50);
>> [X,Y] = meshgrid(xx,yy);
>> Z = griddata(x,y,z,X,Y);
>> mesh(X,Y,Z), hold on
>> plot3(x, y, z, '.‘, 'MarkerSize',15), hold off
Polynomials and Interpolation
Roots of a Polynomial
Let us consider the polynomial: x5 – 5x3 + 4x = 0
It is equivalent to write it as: 1x5 + 0x4 – 5x3 + 0x2 + 4x + 0 = 0
The polynomial is entered in MATLAB as:
>> P = [ 1 0 -5 0 4 0];
The roots of the polynomial are found by using the function roots:
>> r = roots(P)
r=
0
2.0000
1.0000
-2.0000
-1.0000
It is possible to construct the associated polynomial using the command poly:
>> P_new = poly(r)
P_new =
1.0000 0.0000 -5.0000 -0.0000 4.0000 0
Polynomials and Interpolation

Polynomial Multiplication
The polynomial multiplication is performed using the function conv.
Let us multiply two polynomials
p(x) = 4x3 + 3x2 + 2x + 1 and
q(x) = x3 + 2x2 + 3x + 4

>> p = [4 3 2 1];
>> q = [1 2 3 4];
>> mult = conv(p,q)
mult =
4 11 20 30 20 11 4
Polynomials and Interpolation
Polynomial Addition

MATLAB does not provide a direct function for adding


polynomials. If the two polynomials are of same order, then the
standard array addition will work.
a(x) = x3 + 2x2 + x + 1 and
b(x) = 2x3 – x2 – 5x + 2

a(x) and b(x) may be added as:


>> a = [1 2 1 1]; b = [ 2 -1 -5 2 ];
>> add = a + b
add =
3 1 -4 3
Polynomials and Interpolation
Polynomial Addition (cont.)
But if the two polynomials are of different orders, the polynomial of lower
order must be padded with leading zeros thereby making the orders of the
two polynomials equal (with leading terms zero).
i.e., if a(x) = x3 + 2x2 + x + 1 and
b(x) = 4x4 + 2x3 – x2 – 5x + 2,
Then the polynomials are added as:
>> a = [ 0 1 2 1 1]; b = [4 2 -1 -5 2 ];
>> add = a + b
Pad zero vectors at the
add =
beginning equal to the
4 3 1 -4 3 difference in lengths
However this can be performed smartly in a single step for arbitrary lengths
of a and b as follows:
>> add = [zeros(1, length(b)-length(a) ) a] + [zeros(1, length(a)-length(b) )
b]
add =
4 3 1 -4 3
Polynomials and Interpolation
Polynomial Division

The polynomial division is performed using the function deconv. Let


us multiply two polynomials
a(x) = x3 + 2x2 + 1x + 1 and
b(x) = 4x4 + 2x3 - x2 - 5x + 2

>> a = [ 1 2 1 1];
>> b = [4 2 -1 -5 2 ];
>> [q, r] = deconv(b, a)
q=
4 -6 Quotient when a is divided by b
r=
0 0 7 -3 8 Reminder when a is divided by b
Polynomials and Interpolation
Polynomial Derivatives and Integrals

Function polyder is used to evaluate the derivative of a polynomial and


function polyint is used to evaluate the integral

>> a = [4 11 20 30 20 11 4];
>> polyder (a)
ans =
24 55 80 90 40 11
>> polyint (a, 10) Constant of integration
ans =
0.5714 1.8333 4.0000 7.5000 6.6667 5.5000 4.0000 10.0000
Polynomials and Interpolation
Evaluation

Function polyval is used to evaluate the polynomial at any given


point.
Let us evaluate the polynomial a(x) = x3 + 2x2 + 1x + 1 at x = 2

>> a = [ 1 2 1 1]; x = 2;
>> val_a = polyval (a, x)
val_a =
19
Polynomials and Interpolation
Curve Fitting
Function polyfit is used to fit a least-square curve through data
points.

>> x = [1 2 3 4 5 6 7 8 9 10];
>> y = [-1 1 11 35 79 149 251 391 575 809];
>> p = polyfit(x,y,4); Fitted curve
>> xi = linspace(min(x), max(x), 50);
Data points
>> yi = polyval(p, xi);
>> plot(xi,yi,x,y,’.’)

Fits fourth order


polynomial
Optimization
Minimizing Functions of One Variable
y = humps(x) is a function with strong maxima near x = 0.3 and x = 0.9 and a
minima near 0.6. Humps m file evaluates the function:
1 1
humps x 2 2
6
x 0.3 0.01 x 0.9 0.04
Functions fminsearch and fminbnd are used to Maxima
find the minima. The following code minimizes
function humps
>> [xmin,value] = fminsearch (@humps, 0.4) Hump
xmin = s
0.63703125000000 Initial guess
value =
11.25275427640223
>> [xmin,value] = fminbnd (@humps, 0.4, 0.8)
xmin =
0.63702073090281 Minima
Finds the local
value = minima in this
11.25275416764055 band
Optimization
Minimizing Functions of One Variable
The functions optimser and optimget are used to set and get
parameters for the optimezation functions.

options = optimset (‘param1’, value1, ‘param2’, value2,…)


creates an optimization options structure ‘options’ in which the
named parameters have the specified values.

The commonly used optimset parameters are given below:


display – iter (successive iteratin levels), final (final result)
maxIter - maximum number of iterations allowed
tolx – tolerance in x
tolfun – tolerence on function value

For more detailed parameter list, please refer to MATLAB help.


Optimization
Minimizing Functions of One Variable
The following code illustrates the use of the function optimset.
>> options = optimset(‘display’, ‘final’, ‘tolx’, 0.001, ‘tolfun’, 0.0001);
>> check_tolfun = optimget (options, ‘tolx’)
check_tolfun =
0.00100000000000
>> [xmin,value] = fminsearch (@humps, 0.6,options)
Optimization terminated successfully:
the current x satisfies the termination criteria using OPTIONS.TolX of
1.000000e-003 and F(X) satisfies the convergence criteria using
OPTIONS.TolFun of 1.000000e-004
xmin =
0.63656250000000
value =
11.25281476358558
Optimization
Minimizing Functions of Several Variables
The banana function, f(x)= 100(y - x2)2 + (1 - x)2, has a unique minimum at
(1,1). In order to use the function fminsearch, the function must be
rewritten in terms of x = x(1), and y = x(2) as: f(x)= 100( x(2) – x(1)2)2 + (1
– x(1))2.

>> ezmesh('100*(y-x^2)^2 + (1-x)^2',[-1.5,1.5,-1,3])


>> F = ['100*(x(2)-x(1)^2)^2 + (1-x(1))^2'];
>> [xmin, value, flag, output] = fminsearch (F, [-2,2])
xmin =
1.00001666889480 1.00003447386277
value =
4.068551535063419e-010
flag =
1
output =
iterations: 114
funcCount: 210
algorithm: 'Nelder-Mead simplex direct search'
Optimization
Finding Zeros of Functions

x = fzero(fun,x0) tries to find a


zero of the function fun near x0.

>> x_zero = fzero(@humps,1.0) Humps


x_zero =
1.29954968258482

>> x_zero = fzero(@humps,-1.0)


x_zero =
-0.13161801809961 Crosses zero at approx. -0.15 and 1.3
Optimization
Finding Zeros of Functions (cont.)
Using function optimset to display the details when the function is running.
>> options = optimset('display','iter');
>> [x,value] = fzero(@humps,1.28,options)
Func-count x f(x) Procedure
1 1.28 0.453496 initial
2 1.2438 1.43147 search
3 1.3162 -0.351057 search
Looking for a zero in the interval [1.2438, 1.3162]
4 1.30194 -0.0523659 interpolation
5 1.29953 0.000394619 interpolation
6 1.29955 -2.4949e-006 interpolation
7 1.29955 -1.17979e-010 interpolation
8 1.29955 0 interpolation
Zero found in the interval: [1.2438, 1.3162].
x=
1.29954968258482
value =
0
Optimization
Finding Zeros of Functions (cont.)

Using function optimset to set the tolerance and to display the final
result.
>> options = optimset('display','final','tolx',0.001);
>> [x,value] = fzero(@humps,1.28,options)
Zero found in the interval: [1.2438, 1.3162].
x=
1.29933971772587
value =
0.00462447899074
Integration and Differentiation
Integration
b
quad (f, a, b, tol) (Simpson quadrature)
f x dx
a
quadl (f, a, b, tol) (Lobatto quadrature)
y max x max
f x, y dx.dy
y min x min

dblquad (f, xmin, xmax, ymin, ymax,tol)

z max y max x max


f x, y dx.dy.dz
z min y min x min

triplequad (f, xmin, xmax, ymin, ymax, zmin, zmax, tol)


Integration and Differentiation
1D Integration

>> F_humps = @humps;


>> quad (F_humps, -2, 2)
ans =
20.85827278754551
>> quadl (F_humps, -2, 2)
ans =
20.85827267352937
Integration and Differentiation
2D Integration
>> ezsurf('sin(x)*(exp(y)+exp(-y))',[0,pi,-2,2]);
>> func2D = 'sin(x)*(exp(y)+exp(-y))';
>> area = dblquad(@func2D, 0, pi, -2, 2)
area =
3.63718966021828
Integration and Differentiation
Differentiation
Forward Difference
dy xi f xi 1 f xi 1 f(xi-1)
f(xi)
dx xi 1 xi 1

Backward Difference f(xi+1)


dy xi f xi f xi 1

dx xi xi 1
xi-1 xi xi+1
Central Difference
dy xi f xi 1 f xi
dx xi 1 xi
Integration and Differentiation
Differentiation
diff (x, n, dim) is the nth difference function
along dimension ‘dim’.
The default n is 1.
The default dimension is the first dimension of x.

Example:
diif(x) will evaluate the 1st derivative of x along 1st dimension
(row difference in 2D matrix).
diif(x,2) will evaluate the 2nd derivative of x along 1st
dimension.
diff(x,1,2) will evaluate the 1st derivative of x along 2nd
dimension.
Integration and Differentiation
Differentiation
Example: Let us find the 1st derivative of sin(x)

>> dx = .01;
>> x = 0:dx:2*pi; sin x
>> y = sin(x);
>> dy_dx = diff(y)/dx; d sin x
% This determines the central derivative dx
at points (x(i)+x(i+1))/2
>> len_x = length(x); % Length of x
>> xx = (x(2:len_x)+x(1:len_x-1))/2;
>> plot (x, y, xx, dy_dx)
Integration and Differentiation
Differentiation
Example: Let us find the 2nd derivative of sin(x)
>> dx = .01;
>> x = 0:dx:2*pi; sin x
>> y = sin(x);
>> d2y_dx2 = diff(y,2)/(dx).^2; d 2 sin x
% This determines the 2nd dx 2
derivative at point x(i)
>> len_x = length(x); % Length
of x
>> xx = x(2:len_x-1);
>> plot(x,y,xx,d2y_dx2)

dy 2 xi f xi 1 2 f xi f xi 1
Note: dx 2 2
x
Integration and Differentiation

Differentiation
[fx, fy] = gradient(f, dx, dy) returns the numerical gradient of
the matrix ‘f’,
where,
‘fx’ corresponds to df/dx and fy corresponds to df/dy
‘dx’ and ‘dy’ specify the spacing between the coordinate
points.
The default values of ‘dx’ and ‘dy’ are equal to 1.
[f1, f2, f3, …, fn] = gradient (f, d1, d2, …, dn) returns the
numerical gradient of the n-dimensional matrix with the
gradients in the respective directions as f1, f2, …, fn and the
spacing between the points in the different directions to be
d1, d2, …, dn respectively.
Integration and Differentiation
Differentiation
Example: Let us determine the derivatives of the function peaks.

>> dx = 0.25;
>> dy = 0.25;
>> x = -3:dx:3;
>> y = -3:dy:3;
>> [X, Y] = meshgrid (x, y);
>> Z = peaks (X,Y);
>> contour(X,Y,Z)
>> hold on
>> [dzdx,dzdy] = gradient(Z,dx,dy);
>> quiver(X,Y,dzdx,dzdy)
The user Equations
Differential may choose from a
number of alternative functions,
Differential e.g., ode23, ode45, ode113 etc.
Equations
[t, y] = ode…(odefun, tspan, y0) with tspan = [t0 tfinal], solves
the ordinary differential equation:
y f t , y , y t0 y0
The ODE solvers accept only first-order differential equations.
To use the ODS solvers to solver equations involving higher order
derivatives, the ODE’s must be expressed as an equivalent system of first-
order differential equations.

Example: Let us express the following second order ODE as a equivalent


system of first order ODE’s, y 1 0.5 y 2 y y 0, y 0 1, y 0 0
The above set of equations may be written as:
y1 y, y2 y
y1 y2 , y1 0 1

y2 1 0.5 y 2 y2 y1 , y2 0 0
Differential Equations
Differential Equations t<0
T = Ti = 1500K
Example: The solid metal blocks are
heated to 1500K and suddenly dropped to
a cold fluid (T =300K). Estimate the
temporal variation of temperature of the
block.
Assume: h = 20W/m2.K, k = 40W/m, m =
T(t)
0.1 Kg, A = 0.005 m2, cp = 600 J/Kg.K,
= 0.9.
The governing differential equations are: T = 300K
dT
m.c p qlost qconv qrad
dt Eout Econv Erad
where, qconv h. A. T t T , qrad . A. T 4 t T4

Therefore the GDE final equation becomes EST


dT h. A . A 4
. T t T .T t T4
dt m.c p m.c p

You might also like