Comparing single element of one array with values of another array
古いコメントを表示
I have an array A which is mx1. I have a second array, B, which is nx2. I would like to find the values of A which fall in between the two values of B in each row.
for k = 1:size(B,1);
[row, col] = find(A>=B(k,1)&&A=<B(k,2));
end
When I run this I run into two problems.
1) A>=B(k,1) (or the other inequality) throws an error about matrix dimension mismatch. I know that I can compare A>=a where a is a single double value, so why does it cause a problem when I am comparing against a single value of the other matrix? Is it possible to work around this without creating a new variable with just that value?
2) I have problems using the && or expressions. I am able to create two different logical variables on either side of the expression (like in the sample code, pretending it works), but when placed together the error, "Operands to the and && operators must be convertible to logical scalar values," is produced. It seems to me that the && and expressions only seem to work with single logical expressions, rather than arrays of logical results. Is this true?
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Resizing and Reshaping Matrices についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!