finding an closest possible element in an 7 dimensional matrix array
Mostrar comentarios más antiguos
Hi,
Code is as follows
time = period_fun(2,2,1,10,10,15,3) is a 7D matrix with has domensions 2*7*1*10*10*15*8
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
So when hardcode the time = 26.601 and pass it.
I am trying to find the closest value possible in period_arr
%finding the closest element possible to time = 26.601
dist = abs(period_fun - time);
min_dist = min(dist(:));
idx = find(dist == min_dist );
disp(period_arr(idx))
The output comes as 26.601, which is wrong.
My array has a value 26.801 which is closer to 26.601 it is not able to pick that value.
How can i precisely tune it ? so that i can make it more robust for even 0.001 variation
Please help me out
4 comentarios
Ameer Hamza
el 18 de Abr. de 2020
Editada: Ameer Hamza
el 18 de Abr. de 2020
If this line
disp(period_arr(idx))
displays 26.601, then it indicates that your matrix does have an element with value 26.601. I don't think there is any other explanation here.
Also, this line shoule be
min_dist = min(dist(:));
Ganesh Kini
el 18 de Abr. de 2020
Editada: Ganesh Kini
el 18 de Abr. de 2020
Ameer Hamza
el 18 de Abr. de 2020
Can you attach the data in your array period_arr?
Ganesh Kini
el 18 de Abr. de 2020
Editada: Ganesh Kini
el 18 de Abr. de 2020
Respuesta aceptada
Más respuestas (1)
Image Analyst
el 18 de Abr. de 2020
0 votos
If you have the Statistics and Machine Learning Toolbox, try knnsearch(). I think you can have every point be a new class. It will tell you which point is closest to your query point.
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!