833 views
1 vote
Given the following vectors: x=[2 4 0 8 10 12] y=[2 -4 7 10 10 -10] If z = find (x==max(x)), what is the value of z?

a) 5
b) 4
c) 6
d) 3

1 Answer

3 votes

Final answer:

The value of z is 1.

Step-by-step explanation:

To find the value of z when z = (x==max(x)), we need to understand what this expression represents. The expression x==max(x) compares each element of the vector x with the maximum value in x. It returns a logical vector where each element is true if the corresponding element in x is equal to the maximum value, and false otherwise. So, z will have the same length as x, and it will have true at indices where the elements in x are equal to the maximum value, and false elsewhere.

In this case, x=[2 4 0 8 10 12]. The maximum value in x is 12, so z=[false false false false false true]. Therefore, the value of z is 1, indicating that the last element of x is equal to the maximum value.

User Krishna Kalyan
by
8.3k points