How to access data from "Structure within structures" ?

1 visualización (últimos 30 días)
Avnish Patel
Avnish Patel el 26 de Feb. de 2016
Editada: Avnish Patel el 26 de Feb. de 2016
I am beginner I have structure "Sdata" of struct. Which Contains 10 struct. From these every struct, How can I extract 3rd and 4th value?

Respuesta aceptada

Stephen23
Stephen23 el 26 de Feb. de 2016
Editada: Stephen23 el 26 de Feb. de 2016
If every field has the same size, then this will work:
M = vertcat(Sdata.BoundingBox);
M(:,3:4)
And here is a simple example of it being used. First define some fake data in a 1x3 structure:
>> S(1).B = [8,9,Inf,NaN];
>> S(2).B = [4,5,6,7];
>> S(3).B = [0,1,2,3];
then extract the 3rd and 4th columns of every field:
>> M = vertcat(S.B);
>> M(:,3:4)
ans =
Inf NaN
6 7
2 3
Read this to know how it works:
  1 comentario
Avnish Patel
Avnish Patel el 26 de Feb. de 2016
Editada: Avnish Patel el 26 de Feb. de 2016
Thanks Stephen, It work. Thanks for quick reply.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Structures en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by