How can I check if a value in one array is in between two values in another array?
Mostrar comentarios más antiguos
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.
Respuestas (1)
Steven Lord
el 16 de Sept. de 2020
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'})
Categorías
Más información sobre Resizing and Reshaping Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!