update vector with nubers from another vector

Hi
I have a vector A = [ 2 4 6 10 15] and another vector B = [2.43 2.3 12 5.1]
How can I transform so that B = [2 2 10 6] with the help of A.

2 commentaires

the cyclist
the cyclist le 28 Nov 2019
Is the rule that for each value in B, you want the closest value in A?
Karl Persson
Karl Persson le 28 Nov 2019
Yes! exactly.

Connectez-vous pour commenter.

 Réponse acceptée

A = [ 2 4 6 10 15];
B = [2.43 2.3 12 5.1];
[~,idx] = min(abs(B'-A),[],2);
B = A(idx)

Plus de réponses (0)

Catégories

En savoir plus sur Fourier Analysis and Filtering 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!

Translated by