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.

extractfield

Field values from structure array

Syntax

a = extractfield(s, name)

Description

a = extractfield(s, name) returns the field values specified by the field named name into the 1-by-n output array a. n is the total number of elements in the field name of structure s, that is, n = numel([s(:).(name)]). name is a case-sensitive character vector defining the field name of the structure s. a is a cell array if any field values in the field name contain a character vector or if the field values are not uniform in type; otherwise a is the same type as the field values. The shape of the input field is not preserved in a.

Examples

% Plot the X, Y coordinates of the road's shape
roads = shaperead('concord_roads.shp');
plot(extractfield(roads,'X'),extractfield(roads,'Y'));

% Extract the names of the roads
roads = shaperead('concord_roads.shp');
names = extractfield(roads,'STREETNAME');

% Extract a mix-type field into a cell array
S(1).Type = 0;
S(2).Type = logical(0);
mixedType = extractfield(S,'Type');

See Also

|

Introduced before R2006a

Was this topic helpful?