Sorting arrays after finding closest values
Afficher commentaires plus anciens
Hi, I am trying to find a way to find the closest 2,3,4 values inside two sets of (x,y) values to each number in a set of three values. The three values are X values so I just need to find the closest X values and then resize the X and the Y arrays. I was thinking of using the knnsearch function but I'm not sure if that works since the three values (x1 array) would not match up with the 6 values.
x = [1 2 3 5 7 8]; % x values
y = [3 6 19 99 291 444]; % y values
x1 = [2.8 4.4 7.1]; % find the closest 2,3,4 x points to each x1 and then resize x and y arrays
% into 2,3,4 values
%% so for 2.8 (2 closest), x = [2 3] , y =[6 19]
%% 2.8 ( 3 closest), x = [1 2 3], y = [3 6 19]
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Shifting and Sorting Matrices dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!