How do i add tolerance to the code. PLS HELP.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Sarthak Jakar
el 2 de Abr. de 2022
Comentada: Sarthak Jakar
el 3 de Abr. de 2022
MIE is has 3501 values inside it and MIE_2 is a single value. I am trying to find the index of MIE_2 value inside the MIE with next closest possible value so as to plot it using indexing. since MIE_2 us calculated using expression, upto 4 decimals it does not match with values in MIE.
tol = 0.0001;
MIEIdx = find(MIE == (MIE_2),1,'first');
0 comentarios
Respuesta aceptada
Walter Roberson
el 2 de Abr. de 2022
MIEIdx = find(abs(MIE_2 - MIE) <= tol);
This might have 0 or more matches.
You might also be interested in
[dist, MIEIdx] = min(abs(MIE_2 - MIE));
if dist > tol
%no match
else
%MIEIdx is the match
end
3 comentarios
Walter Roberson
el 3 de Abr. de 2022
No, that first code finds all of the values that are within the tolerance, not just the nearest.
Más respuestas (0)
Ver también
Categorías
Más información sobre Geographic Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!