Hello everyone and welcome to MATLAB
tutorial video is brought to you by
MATLAB helper and in this video tutorial
I'm going to show you how to perform error
analysis in MATLAB. Error can be
associated with both calculated and
measured quantities and it can be
characterized using accuracy and
precision
now accuracy refers to how closely the
measure or the calculated values agree
with the true value or the true quantity
whereas precision refers to how
closely the individually calculated or
measured value agrees with each
other.
Considering the example of a person
trying to hit a bull's eye we can see in
the figure there are four situations
wherein the gunshots are fired and you
can see in part A, this fired gunshots
are not accurate neither are they precise
whereas moving onto B, the accuracy
increases as all the gunshots are
centered near the bull's eye but they
are not precise. In the figure C,
these gunshots are not accurate but they are
precise because they're centered
somewhere on the upper left corner of
the target whereas moving on to D, these
shots are both precise and accurate and
now you can understand the difference between
accuracy and precision. Moving on to errors,
I'm going to focus on five different
errors in this video tutorial focusing
on the first two namely the Absolute
error and the Relative error. Now one
can easily differentiate between
absolute and relative errors as absolute error is magnitude of difference
between the true value and the
approximation
whereas relative error is the percent of
error that occurs as a true value. So
both of this can be calculated using the
equation shown on screen. Now let's try
implementing the same in MATLAB. Let's
say our true value is the value PI
whereas our approximate value
is 3.14. Now we
can calculate error absolute as true value
minus approximate value. So that is the
absolute error whereas if you try calculating
relative error it can be
calculated using absolute error divided
by true value that is the value of relative
error. Another type of error that I'm
going to talk about is the round off
errors. Now these type of errors usually
occur in the digital computers are not
able to trip display or represent value
exactly. Such type of error usually
occurs during engineering or
scientific application trying to
represent that in MATLAB picking
implement of for loop. Let's say R is equal to
0 initially and when we implement a for loop  that will run from 1 to
10,000 and keep on adding S with
0.0001. So in the end,
we should get something equal to 1, but
due to the factor called round of error
you will see the value of S to be
something like this. So that is the error.
Another type of error is the
truncation error. Now, this kind of error occur
because of using
approximate values in place of exact
values. For example Maclaurin series, consider if you want to calculate the value
of sin(pi/2) using Maclaurin series,
the way you will do that is
let's say my S is zero for starters and
I'll form a for loop that will run from
0 to 5 and my S will
be updated with this. So that is the
value of sin(pi/2) calculated using
the Maclaurin series and if we actually try to
calculate the value of sin(pi/2), it
turns out to be 1, so the difference
between these two values is known as 
truncation error. Moving on to the final
type of error. The total numerical error. Now
total numerical error is actually sum of
truncation errors and round off errors. This 
total numerical error can be reduced by
reducing the round off errors which will
only happen if we try to increase the
number of significant figures in a
number more precise, whereas if we try to
reduced random errors, truncation
error increases and vice versa. So
that is about errors in MATLAB. I hope
you enjoyed this video and it was a
helpful video for you guys if you liked
it please hit the thumbs up button or
subscribe if you want to keep yourself
updated if you have any queries or
doubts all suggestions for different
topics you want us to cover please leave
it in the comment section down below and
we will get back to you with it thank
you for watching this video bye
