# Serach whether numbers of different arrays are close to each other

1 Ansicht (letzte 30 Tage)
JamJan am 8 Mai 2019
Bearbeitet: Adam Danz am 13 Mai 2019
I have 8 arrays of numbers. I want to know whether the numbers of these 8 arrays are close to each other. So for instance
Array1: 1 100 250 400
Array2: 30 89 170 800
Array3: 20 51 870
I want to know whether the numbers meet the condition of being closer than 50 to each other. How do I do this?
##### 1 Kommentar-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden
Jan am 9 Mai 2019
What is the wanted output for these 3 inputs? You mention 8 arrays. What exactly does "closer than 50 to each other" mean e.g. for the 3 values: [10, 69, 118]? Are they or aren't they closer than 50? Then what about [10, 69, 118, 167]?
The question is not uniquely defined yet. Please edit the original message and add more details.

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

Adam Danz am 8 Mai 2019
Bearbeitet: Adam Danz am 13 Mai 2019
A = [20 51 870]; % Input vector
w = 50; % Distances less than this are considered "close"
dA = abs(diff(A))< w; % Identify which values are "close"
any(dA) % TRUE if any of the distances are less than 50
all(dA) % TRUE if all of the distances are less than 50
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Operators and Elementary Operations finden Sie in Help Center und File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by