How can I check if a value in one array is in between two values in another array?
Afficher commentaires plus anciens
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.
Réponses (1)
Steven Lord
le 16 Sep 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'})
Catégories
En savoir plus sur Resizing and Reshaping Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!