This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.


Field values from structure array


a = extractfield(s, name)


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.


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

% 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?