array of structures in matlab

1 visualización (últimos 30 días)
sweta arya
sweta arya el 10 de Oct. de 2015
Comentada: Walter Roberson el 10 de Oct. de 2015
how to create array of structure,and array contains 100 element. i want to sort array on the basis of second field of array.

Respuesta aceptada

Walter Roberson
Walter Roberson el 10 de Oct. de 2015
YourStructureName(100) = struct('firstfield', [], 'secondfield', []);
And there you have a struct array of 100 elements, each of which has two fields.
  2 comentarios
sweta arya
sweta arya el 10 de Oct. de 2015
how to sort this array on the basis of second field.thank you
Walter Roberson
Walter Roberson el 10 de Oct. de 2015
There is no basis for sorting an array based upon empty fields. If the fields are not empty then you need to define how to determine whether one field content sorts before another. For example if YourStructure(317).secondfield = {'Red Rover', 17}, should that sort before or after YourStructure(111).secondfield = [1/1000-3/507i, inf; nan, -5099e42] ?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Shifting and Sorting Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by