val2ind

バージョン 1.0.0.0 (1.24 KB) 作成者: Tom O'Haver
Returns the index and the value of the element of vector x that is closest to val
ダウンロード: 2.1K
更新 2006/10/25

ライセンスの表示

function [index,closestval]=val2ind(x,val)
A very simple 3-line function that returns the index and the value of the element of vector x that is closest to a particular numerical value.
If more than one element is equally close, returns vectors of indicies and values.
Examples: If x=[1 2 4 3 5 9 6 4 5 3 1], then val2ind(x,6)=7 and val2ind(x,5.1)=[5 9]
[indices values]=val2ind(x,3.3) returns indices = [4 10] and values = [3 3].

Sample use: to determine the index and value of an element of a vector from the x,y values obtained by clicking on a plot of that vector using ginput.

引用

Tom O'Haver (2024). val2ind (https://www.mathworks.com/matlabcentral/fileexchange/12782-val2ind), MATLAB Central File Exchange. 取得済み .

MATLAB リリースの互換性
作成: R13
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
カテゴリ
Help Center および MATLAB AnswersVisual Exploration についてさらに検索
タグ タグを追加

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
バージョン 公開済み リリース ノート
1.0.0.0