store data from different structures into one variable
Mostrar comentarios más antiguos
I have a structure with multiple variables and under each variable are cells that have their own structure. I want to go through each one of these cells (85) and grab some specific values that is 320 each and store them into another variables all together to create one large structure (320x85). Is this possible? Should a loop be used? It seems like I can only read the first entry under my desired variable with this code:
for w = 1:numel(matData)
baseAcc = matData(w).results.learn.acc;
data.acc(w) = fullfile(baseAcc);
end
the matData file is a structure that is 1x85 with 4 fields (results being one of them).
2 comentarios
Jan
el 6 de Jul. de 2021
"I have a structure with multiple variables and under each variable are cells that have their own structure."
It helps to understand the question, if you use the standard expressions. You have a struct array (not "structure") with nested fields (not "multiple variabels"). What are the cells now and which are "their own structure/structs"? Which field has the dimension 320?
Why do you use fullfile with a single input? This replies the input as output.
Of course you can join the data to an array using a loop. Maybe:
acc = zeros(320, numel(matData));
for w = 1:numel(matData)
acc(:, w) = matData(w).results.learn.acc;
end
Sam N
el 6 de Jul. de 2021
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Variables 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!