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

4 visualizzazioni (ultimi 30 giorni)
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.

Risposte (1)

Steven Lord
Steven Lord il 16 Set 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'})

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by