Find the key for vector transformation
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Ali
el 27 de Sept. de 2022
Comentada: Ali
el 27 de Nov. de 2022
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);
0 comentarios
Respuesta aceptada
Walter Roberson
el 27 de Sept. de 2022
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
Kp(idx,:)
5 comentarios
Walter Roberson
el 28 de Sept. de 2022
That's why I was talking about custom functions to enforce integer permutation.
Más respuestas (1)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!