[MUSIC]

We've been doing comparisons in the conditions of if statement with

expressions like x equals equals 2.

The double equal is an example of a so-called relational operator.

Relational means the result depends on the relation between the operands.

This table lists all six MATLAB's relational operators.

We seen how to use these operators inside if statements, what maybe surprising

is that they can also be used outside if statements and they produce values.

Let's take a look at this other way to use relational operators.

Let's see.

10 double equals 20,

answer equals 0.

3 double equals 35 minus

32, answer equals 1.

In the first example, we asked MATLAB to calculate the value of

the expression 10 double equals 20 and it told us that the value's 0.

In MATLAB, when the operator double equals finds that its first operand,

like 10 is not equal to its second operand, like 20.

It returns the value zero, which means false.

In the second example, we found that the value of the expression

3 double equals 35 minus 32 is 1,

because 35 minus 32 is 3 and so 3 double equals 3 is true.

And when the double equals operator finds that its first operand is equal

to its second operand, it returns the value one, which means true.

In fact, every relational operator returns zero when its expression is false and

one when its expression is true.

And when we say, zero and one, we mean the numbers zero and one.

Here's an example to drive home

the fact that the result for

relational operation is a number.

In this expression, 16 times 64 ,which

evaluates to 1,024 is greater than 1,000.

So the relational expression in parenthesis evaluates to one,

which is true of course.

We then add 9 to 1 and get 10.

So the value of 16 times 64 greater than a 1, 000 is a 1, a normal 1.

The kind of one that you can do arithmetic with not some special one that

has some special sort of truthiness attribute attached to it.

The parentheses have an important effect here.

If we omit them, we get a different answer.