Combining rows of each field within a structure
28 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Josh Tome
el 30 de Nov. de 2022
Respondida: Image Analyst
el 30 de Nov. de 2022
Hello,
I'd like to combined the rows of a structure for each field. I won't always know how many rows there will be in the structure. The example I show is a 1 x 3 structure, but I'd like to plan for a 1 x ? structure. So I thought combining the rows in a for loop would be the best way. I'm aiming for a 3 x 101 double in each of the fields in this example.
I'm sure there's a pretty easy solution to this but I'm a novice when it comes to MATLAB
Any help would be greatly appreciated!
2 comentarios
Image Analyst
el 30 de Nov. de 2022
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
Respuesta aceptada
Voss
el 30 de Nov. de 2022
S = load('Combined_Structure.mat','ModOutRstance_interp_x_all');
new_struct = struct();
f = fieldnames(S.ModOutRstance_interp_x_all);
for ii = 1:numel(f)
new_struct.(f{ii}) = vertcat(S.ModOutRstance_interp_x_all.(f{ii}));
end
disp(new_struct);
0 comentarios
Más respuestas (2)
Image Analyst
el 30 de Nov. de 2022
How about this:
s = load('Combined_Structure.mat');
m = s.ModOutRstance_interp_x_all;
allm = vertcat(m.LHipAngles)
0 comentarios
Ver también
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!