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.

getnext

Get next value from ValueIterator

Syntax

X = getnext(ValIter)

Description

example

X = getnext(ValIter) returns the next available value in ValIter. Use the hasnext function to confirm availability of values in ValIter before calling getnext.

Examples

collapse all

Use the hasnext and getnext functions in a while loop within the reduce function to iteratively get values from the ValueIterator object. For example,

function MeanDistReduceFun(sumLenKey, sumLenIter, outKVStore)
    sumLen = [0 0];
    while hasnext(sumLenIter)
        sumLen = sumLen + getnext(sumLenIter);
    end
    add(outKVStore, 'Mean', sumLen(1)/sumLen(2));
end

Always call hasnext before getnext to confirm availability of a value. mapreduce returns an error if you call getnext with no remaining values in the ValueIterator object.

Input Arguments

collapse all

Intermediate value iterator, specified as a ValueIterator object. The mapreduce function automatically creates this object during execution. The second input to the reduce function specifies the variable name for the ValueIterator object, which is the variable name to use with the hasnext and getnext functions.

For more information, see ValueIterator.

Introduced in R2014b

Was this topic helpful?