find the values of a that are between 2 and 6(inclusive)

12 次查看(过去 30 天)
A>>
7.24 0.80 *7.31* *9.24* *3.09*
1.06 0.06 *8.97* *1.37* *0.55*
8.67 8.88 *9.92* *0.71* *0.90*
3.45 9.01 *9.15* *4.80* *2.29*
4.56 5.16 *5.33* *7.10* *7.61*
1.16 0.64 *0.08* *8.76* *8.06*
8.96 6.23 *9.96* *6.93* *7.71*
8.15 6.84 *6.95* *1.88* *7.36*
4.75 1.54 0.28 3.10 9.04
[r,c]=find(A<=2 & A<=6) is this right?

采纳的回答

Image Analyst
Image Analyst 2012-12-4
Some things to try:
A=[7.24 0.80 7.31 9.24 3.09
1.06 0.06 8.97 1.37 0.55
8.67 8.88 9.92 0.71 0.90
3.45 9.01 9.15 4.80 2.29
4.56 5.16 5.33 7.10 7.61
1.16 0.64 0.08 8.76 8.06
8.96 6.23 9.96 6.93 7.71
8.15 6.84 6.95 1.88 7.36
4.75 1.54 0.28 3.10 9.04]
linearIndexes = A>=2 & A<=6;
[rows, columns]=find(linearIndexes)
inRange = A(linearIndexes)

更多回答(1 个)

Walter Roberson
Walter Roberson 2012-12-4
Any value that is <= 2 will also be <= 6 . Reconsider your comparisons.

类别

Help CenterFile Exchange 中查找有关 Multidimensional Arrays 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by