SORTFIELDS

Versión 1.0.0.0 (2,07 KB) por Ian Howat
SORTFIELDS sort values in all fields within a structure.
2,1K Descargas
Actualizado 25 ago 2008

Ver licencia

%SORTFIELDS sort values in all fields within a structure.
% SORTFIELDS(A) sorts the rows of each field of structure A in asending
% order and returns a structure of the same dimension and field names.
% SORTFIELDS(A,'SORTBYFIELD','FIELDNAME',...) sorts each field by the
% specified field. All fields must be the same size.
% SORTFIELDS(A,'PARAMETER1','VALUE1','PARAMETER2','VALUE2',....) uses the
% properties:
% DIM selects a dimension along which to sort.
% MODE selects the direction of the sort
% 'ascend' results in ascending order
% 'descend' results in descending order
%
% EXAMPLES:
% >> A.field1 = [9,1,8,2,7,3,6,4,5]; A.field2 = fliplr(A.field1)
% A =
% field1: [9 1 8 2 7 3 6 4 5]
% field2: [5 4 6 3 7 2 8 1 9]
% >> B = sortfields(A)
% B =
% field1: [1 2 3 4 5 6 7 8 9]
% field2: [1 2 3 4 5 6 7 8 9]
% >> B = sortfields(A,'sortbyfield','field1')
% B =
% field1: [1 2 3 4 5 6 7 8 9]
% field2: [4 3 2 1 9 8 7 6 5]
% >> B = sortfields(A,'sortbyfield','field1','mode','descend','dim',2)
% B =
% field1: [9 8 7 6 5 4 3 2 1]
% field2: [5 6 7 8 9 1 2 3 4]

Citar como

Ian Howat (2025). SORTFIELDS (https://la.mathworks.com/matlabcentral/fileexchange/21209-sortfields), MATLAB Central File Exchange. Recuperado .

Compatibilidad con la versión de MATLAB
Se creó con R2007b
Compatible con cualquier versión
Compatibilidad con las plataformas
Windows macOS Linux
Categorías
Más información sobre Structures en Help Center y MATLAB Answers.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Versión Publicado Notas de la versión
1.0.0.0