structures consolidation and manipulations
Mostrar comentarios más antiguos
Hello I have a basic question on structures I have a struct a which can contain n fields So for example
a(1)
=
mydata:[135x6]
myid:{1x6}
mydates = [135x1]
mytel=
myname=
etc
and so on for a(2), a(3)...etc to m
I want to then do some manipulation on the data say my own function transform which takes a(1) as an input and produces a(1).stats
Then I want to consolidate all my m objects into one big structure say BigStruct that has all the fields that a had plus the stats
such that
BigStruct =
mydata =[135x1000]
mydates = [135x1000]
etc
etc
Again I am doing all this in a for loop and was wondering if there is an easier elegant method to do this
Thanks so much
2 comentarios
Azzi Abdelmalek
el 21 de Ag. de 2013
Are you looking for elegant way or fastest way?
Azzi Abdelmalek
el 21 de Ag. de 2013
Editada: Azzi Abdelmalek
el 21 de Ag. de 2013
You did not specify if the concatenation is always horizontal or vertical?
Respuesta aceptada
Más respuestas (1)
Azzi Abdelmalek
el 21 de Ag. de 2013
Editada: Azzi Abdelmalek
el 21 de Ag. de 2013
For vertical concatenation
names=fieldnames(a);
for k=1:numel(names)
b.(names{k})=cat(1,a(:).(names{k}));
end
b
1 comentario
hdg D
el 22 de Ag. de 2013
Categorías
Más información sobre Data Type Conversion en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!