update vector with nubers from another vector
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Karl Persson
am 28 Nov. 2019
Kommentiert: Karl Persson
am 28 Nov. 2019
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 Kommentare
Akzeptierte Antwort
the cyclist
am 28 Nov. 2019
A = [ 2 4 6 10 15];
B = [2.43 2.3 12 5.1];
[~,idx] = min(abs(B'-A),[],2);
B = A(idx)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Language Fundamentals 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!