Skip to content

ndi.fun.docTable.docCellArray2Table

 DOCCELLARRAY2TABLE Convert a cell array of ndi.document objects to a single table.
    T = DOCCELLARRAY2TABLE(DOC_CELL_ARRAY) takes a cell array of
    ndi.document objects, converts each to a table using its `to_table`
    method, and then vertically stacks them into a single table.

    DESCRIPTION:
    This function serves as a convenient wrapper to process a batch of
    ndi.document objects. It first iterates through the input cell array,
    calling the `to_table()` method on each document. The resulting list of
    tables is then passed to `ndi.fun.table.vstack`, which intelligently
    merges them, handling any discrepancies in columns (fields) across
    the different documents.

    INPUTS:
    doc_cell_array - A 1xN cell array where each element is an object of
                     class `ndi.document`.

    OUTPUTS:
    T - A single MATLAB table representing the combined data from all input
        documents. If the input cell array is empty, an empty table is
        returned.

    EXAMPLE:
    % Assume doc1 and doc2 are valid ndi.document objects.
    % doc1 might produce a table with columns {'name', 'value'}
    % doc2 might produce a table with columns {'name', 'timestamp'}
    doc_list = {doc1, doc2};
    combined_table = ndi.fun.docTable.docCellArray2Table(doc_list);
    % combined_table will have columns {'name', 'value', 'timestamp'},
    % with appropriate fill values (e.g., NaN, <missing>) for absent data.

    SEE ALSO:
    ndi.document, ndi.document/to_table, ndi.fun.table.vstack