Page 44 - Numerical Analysis Using MATLAB and Excel
P. 44
Display Formats
zmax =
1/((x-1/10)^2+1/100)^2*(2*x-1/5)-1/((x-6/5)^2+1/25)^2*(2*x-12/5)
solve(zmax)
When the command
solve(zmax)
is executed, MATLAB displays a very long expression which when copied at the command
prompt and executed, produces the following:
ans =
0.6585 + 0.3437i
ans =
0.6585 - 0.3437i
ans =
1.2012
ans =
0.0999
From the values above we choose x = 0.0999 which is consistent with the plots of Figures 1.15
and 1.16. Accordingly, we execute the following script to obtain the value of ymin .
x=0.0999; % Using this value find the corresponding value of ymax
ymax=1 / ((x−0.1) ^ 2 + 0.01) −1 / ((x−1.2) ^ 2 + 0.04) −10
ymax = 89.2000
1.10 Display Formats
MATLAB displays the results on the screen in integer format without decimals if the result is an
integer number, or in short floating point format with four decimals if it a fractional number. The
format displayed has nothing to do with the accuracy in the computations. MATLAB performs all
computations with accuracy up to 16 decimal places.
The output format can changed with the format command. The available formats can be displayed
with the help format command as follows:
help format
FORMAT Set output format.
All computations in MATLAB are done in double precision.
FORMAT may be used to switch between different output display
formats as follows:
Numerical Analysis Using MATLAB® and Excel®, Third Edition 1−31
Copyright © Orchard Publications