Documentation

getnext

Get next value from ValueIterator

Syntax

X = getnext(ValIter)

Description

example

X = getnext(ValIter)returns the next available value inValIter. Use thehasnextfunction to confirm availability of values inValIterbefore callinggetnext.

Examples

collapse all

Use thehasnextandgetnextfunctions in awhileloop within the reduce function to iteratively get values from theValueIteratorobject. For example,

functionMeanDistReduceFun(sumLenKey, sumLenIter, outKVStore) sumLen = [0 0];whilehasnext(sumLenIter) sumLen = sumLen + getnext(sumLenIter);end添加(outKVStore'Mean', sumLen(1)/sumLen(2));end

Always callhasnextbeforegetnextto confirm availability of a value.mapreducereturns an error if you callgetnextwith no remaining values in theValueIteratorobject.

Input Arguments

collapse all

Intermediate value iterator, specified as aValueIteratorobject. Themapreducefunction automatically creates this object during execution. The second input to the reduce function specifies the variable name for theValueIteratorobject, which is the variable name to use with thehasnextandgetnextfunctions.

For more information, seeValueIterator.

Introduced in R2014b

Was this topic helpful?