How can I check if a value in one array is in between two values in another array?

5 次查看(过去 30 天)
I have an an array of random values and an array of positions. I need to check if the random values fall between two positions, but it needs to be in between values like a1 a2, a3 a4, a5 a6, it cannot be in between a2 a3, a4 a5, etc. Please let me know how to do this! I was going to use the find() function but I'm not sure how to get it to check these values.

回答(1 个)

Steven Lord
Steven Lord 2020-9-16
You want to discretize your data?
edges = 0:2:10;
sampleData = 10*rand(10, 1);
whichBin = discretize(sampleData, edges);
left = edges(whichBin).';
right = edges(whichBin+1).';
results = table(sampleData, whichBin, left, right, ...
'VariableNames', {'Value', 'BinNumber', 'LeftEdge', 'RightEdge'})

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by