Merging Arrays in a Struct and Sorting them

3 visualizaciones (últimos 30 días)
Chris Dan
Chris Dan el 26 de Dic. de 2019
Editada: Stephen23 el 26 de Dic. de 2019
Hello, I have a struct like this:
talha4.JPG
I want to join its two arrays into one array and then sort them in ascending order, I am trying this code, but it is not giving me results:
c = [v(1) v(2)]
sort_c = sort(c);

Respuesta aceptada

Bhaskar R
Bhaskar R el 26 de Dic. de 2019
result = sort(struct2array(v), 'ascend')

Más respuestas (1)

Stephen23
Stephen23 el 26 de Dic. de 2019
Editada: Stephen23 el 26 de Dic. de 2019
A more robust solution, where v is your 2x1 structure:
out = sort([v.IndividualStiffnessMatrix])
Note that your field name is misspelled "Indivual..."

Categorías

Más información sobre Structures 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