Include two MATLAB input statements in the file iteration.m, e.g.
a= input(' enter the value of the lh end of the interval: ');
to enter the the end-points of
the plotting interval for the problem above from the keyboard and store them
in MATLAB variables
a
and
b
.
For our first case these will take the values 0 and
respectively.
In the editor, save the file iteration.m and then run this MATLAB script by typing
>> iteration
at the MATLAB prompt (
>>
)
.
The script should ask you to enter values for
a
and
b
. Make sure you do this.
Create a MATLAB vector
x
running from
a
to
b
in
steps of 0.01
(MATLAB vectors
) .
Use the MATLAB
plot
command (see
plotting
)
to plot the function
above as a function of
.
Use a blue line for the plot.
In the editor, save the file iteration.m and then type iteration at the MATLAB prompt.
Your graph should appear as Figure 1. Use the zoom command in the figure
(click the magnifying glass) and then hold down the left mouse key near
the root
, drag the mouse and release the key to allow you to estimate
the value of
.
Add the commands zoom on and grid on
just after the plot command, then save and re-run iteration.m. You can
now estimate the root
as accurately as you wish.
Record your estimate of the root to exactly four significant figures.