在Matlab中检查行是否满足要求

Chceck if row meet the requirements in Matlab

我连续有这样的特点

...
|  2  |  2.3  |  14  |  1050  |  6  |  500  |  300  |  1500  |
...

我有上限和下限。如何检查我的行是否符合这些界限?

假设你的上限和下限分别存储在upper_bound和lower_bound中:

satisfies_upper_bound = (max(features) < upper_bound);
satisfies_lower_bound = (min(features) > lower_bound);
is_acceptable = (satisfies_upper_bound & satisfies_lower_bound);

希望对您有所帮助!

怎么样?

upper_bounds = rand(1, 10) %random upper bound
lower_bounds = upper_bounds/5 %random lower bound    
row = rand(1, 10) %random row
% answer
satisfied = (row < upper_bounds & row > lower_bounds)

输出:

upper_bounds =

    0.1067    0.9619    0.0046    0.7749    0.8173    0.8687    0.0844    0.3998    0.2599    0.8001


lower_bounds =

    0.0213    0.1924    0.0009    0.1550    0.1635    0.1737    0.0169    0.0800    0.0520    0.1600


row =

    0.4314    0.9106    0.1818    0.2638    0.1455    0.1361    0.8693    0.5797    0.5499    0.1450


satisfied =

     0     1     0     1     0     0     0     0     0     0

我找到问题了。我已经检查了我这样做时发生了什么

A <= lb & A >= ub

我得到了 8x8 矩阵,这不是我需要的。我转置了 lb 和 ub,所以最后我得到了 1x8 (0|1) 矩阵,它解决了我的问题。

感谢大家的贡献!