MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1
2 4 6
8 10 12

B = [5 5 5; 9 9 9]

B =

5 5 5
9 9 9

A < B

ans =

1 1 0
1 0 0

Similarly, you can compare one of the arrays to a scalar.

A > 7

ans =

0 0 0
1 1 1

If you compare a 1 -by-N row vector to an M-by- 1 column vector, then MATLAB expands
each vector into an M-by-N matrix before performing the comparison. The resulting matrix
contains the comparison result for each combination of elements in the vectors.

A = 1:3

A =

1 2 3

B = [2; 3]

B =

2
3

A >= B

ans =

2 Program Components

Free download pdf