I am attaching an example variable and the answer your code should result in should be 175 or the 174 index.
closest value to zero excluding the first one?
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ali Almakhmari
am 12 Jan. 2023
Kommentiert: Bruno Luong
am 12 Jan. 2023
If given a long vector of values. How can I find the index of the closest value to zero excluding the first value of the vector out of our list of stuff to search for
2 Kommentare
Akzeptierte Antwort
Ali Almakhmari
am 12 Jan. 2023
1 Kommentar
Bruno Luong
am 12 Jan. 2023
That is NOT your question asks for, that is first consecutive points where 0 is cross from positive to negative.
Weitere Antworten (2)
Bora Eryilmaz
am 12 Jan. 2023
Bearbeitet: Bora Eryilmaz
am 12 Jan. 2023
load('var.mat')
[~,I] = sort(abs(dis_y), 'ascend');
% Closest value to 0:
dis_y(I(1))
% Second closest value to 0:
dis_y(I(2))
2 Kommentare
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!