Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

val2ind

Uniform grid index

Syntax

Ind = val2ind(Value,Delta)
Ind = val2ind(Value,Delta,GridStartValue)

Description

Ind = val2ind(Value,Delta) returns the index of the value Value in a uniform grid with a spacing between elements of Delta. The first element of the uniform grid is zero. If Value does not correspond exactly to an element of the grid, the next element is returned. If Value is a row vector, Ind is a row vector of the same size.

Ind = val2ind(Value,Delta,GridStartValue) specifies the starting value of the uniform grid as GridStartValue.

Examples

collapse all

Find the index corresponding to 0.0001 in a uniform grid with 1 MHz sampling rate.

fs = 1e6;
indx = val2ind(0.0001,1/fs)
indx =

   101

Find the indices corresponding to a vector of values in a uniform grid with 1 kHz sampling rate. Values are not divisible by 1/fs.

fs = 1.0e3;
values =[0.0095 0.0125 0.0225];
indx = val2ind(values,1/fs)
indx =

    11    14    24

Extended Capabilities

Introduced in R2011a

Was this topic helpful?