필터 지우기
필터 지우기

Find the key for vector transformation

조회 수: 3 (최근 30일)
Ali
Ali 2022년 9월 27일
댓글: Ali 2022년 11월 27일
Hello friends, Below is the optimization work. Even though I woked with fminsearch and similar tools, I cannot figure this out. Any help? Thank you very much. A & B & KEY are vectors of same length. the KEY is unknown. find the KEY such that minimize the function B-A(KEY).
clc;clear
A= [25 21.2 0.4 3.5 15 60 14 8.1 16.9 1.1];
KEY= [3 5 8 1 10 9 7 6 2 4];
B= A(KEY) + rand(1,10);

채택된 답변

Walter Roberson
Walter Roberson 2022년 9월 27일
You do not want to minimize B-A(KEY): those are vectors and you cannot minimize a vector.
A= [25 21.2 0.4 3.5 15 60 14 8.1 16.9 1.1];
KEY= [3 5 8 1 10 9 7 6 2 4];
B= A(KEY) + rand(1,10);
Kp = perms(KEY);
values = sum((B - A(Kp)).^2,2);
[bestresult, idx] = min(values);
bestresult
bestresult = 3.4348
Kp(idx,:)
ans = 1×10
3 5 8 1 10 9 7 6 2 4
  댓글 수: 5
Walter Roberson
Walter Roberson 2022년 9월 28일
That's why I was talking about custom functions to enforce integer permutation.
Ali
Ali 2022년 9월 28일
Thank you so much, I will try ga.

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

추가 답변 (1개)

Matt J
Matt J 2022년 9월 28일
  댓글 수: 1
Ali
Ali 2022년 11월 27일
Thank you for late reply. I saw your comment now, I appreciate and take a look.

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

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by