understand how a logical vector can be used as an address in
understand how a logical vector can be used as an address in math lab
understand how a logical vector can be used as an address in math lab
understand how a logical vector can be used as an address in math lab
Solution
The results of a relational operation with vectors, which are vectors with 0’s and 1’s, are called logical vector and can be used for addressing vectors. When it is for addressing another vector, it extracts from that vector the elements in the positions where the logical vector has 1’s. For example:
>> x = [-2 4 -5 6]; y = [2 8 -4 7];
>> t = x>=0;
>> t
t =
0 1 0 1
>> y(t)
ans =
8 7
