logical函数(逻辑函数)
logical(x):x ~=0时,logical(x)=1;x = 0时,logical(x)=0
注意:
一·logical函数可以将矩阵转化为逻辑矩阵
例:
a =
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
5.2853 9.1334 7.7491 2.6380 5.1325 9.4479 4.0391 0.1540 1.8896 4.3586
1.6565 1.5238 8.1730 1.4554 4.0181 4.9086 0.9645 0.4302 6.8678 4.4678
6.0198 8.2582 8.6869 1.3607 0.7597 4.8925 1.3197 1.6899 1.8351 3.0635
2.6297 5.3834 0.8444 8.6929 2.3992 3.3772 9.4205 6.4912 3.6848 5.0851
6.5408 9.9613 3.9978 5.7970 1.2332 9.0005 9.5613 7.3172 6.2562 5.1077
6.8921 0.7818 2.5987 5.4986 1.8391 3.6925 5.7521 6.4775 7.8023 8.1763
7.4815 4.4268 8.0007 1.4495 2.3995 1.1120 0.5978 4.5092 0.8113 7.9483
>> logical(a)
ans =
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1