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

Find index for 0.001 in uniform grid with 1 MHz sampling rate.

Fs = 1e6;
Ind = val2ind(0.001,1/Fs);
% Ind is 1001 because the 1st grid element is zero

Find indices for vector with 1 kHz sampling rate.

Fs = 1e3;
% Construct row vector of values
Values =[0.0095 0.0125 0.0225];
% Values not divisible by 1/Fs
% with nonzero remainder
Ind = val2ind(Values,1/Fs);
% Returns Ind =[11 14 24]

Introduced in R2011a

Was this topic helpful?