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?
9 ビュー (過去 30 日間)
古いコメントを表示
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
採用された回答
Ali Almakhmari
2023 年 1 月 12 日
1 件のコメント
Bruno Luong
2023 年 1 月 12 日
That is NOT your question asks for, that is first consecutive points where 0 is cross from positive to negative.
その他の回答 (2 件)
Bora Eryilmaz
2023 年 1 月 12 日
編集済み: Bora Eryilmaz
2023 年 1 月 12 日
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))
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!