Conconate arrays horizontally in an automatic manner
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hi,
I have the following matrix:
features_arm.(subjects{q}).(taskname{i}).AccNorm
taskname contains RF1, RF2 & RF3. (reach forward)
I would like to use
horzcat(features_arm.(subjects{q}).RF1.AccNorm,features_arm.subjects{q}).RF2.AccNorm,features_arm.subjects{q}).RF3.AccNorm)
However, not all subjects have RF1, RF2 and RF3 (eg some only have RF1 and RF2).
Would there be an elegant way to conconate the data for all tasks without having to check this manually for each subject?
(I was thinking something in the area of 'RF*', but I am failing to figure something out that works)
Thanks
0 comentarios
Respuestas (1)
dpb
el 28 de Abr. de 2022
"The MATLAB way" around such problems is to not create sequentially-named variables of the type RFn but use either cell arrays or dynamic field names to write generic code.
See the content of the old MATLAB FAQ Wiki at <FAQ#How_can_I_create_variables_A1.2C_A2.2C....>
There used to be a link in the doc to similar content but they've changed the organization and I now no longer find that so easily...
0 comentarios
Ver también
Categorías
Más información sobre Data Type Identification 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!