update vector with nubers from another vector

조회 수: 1 (최근 30일)
Karl Persson
Karl Persson 2019년 11월 28일
댓글: Karl Persson 2019년 11월 28일
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
the cyclist
the cyclist 2019년 11월 28일
Is the rule that for each value in B, you want the closest value in A?
Karl Persson
Karl Persson 2019년 11월 28일
Yes! exactly.

댓글을 달려면 로그인하십시오.

채택된 답변

the cyclist
the cyclist 2019년 11월 28일
A = [ 2 4 6 10 15];
B = [2.43 2.3 12 5.1];
[~,idx] = min(abs(B'-A),[],2);
B = A(idx)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Language Fundamentals에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by